Lars282 Posted December 7, 2012 Share Posted December 7, 2012 Hey, How do you upload images using the API? I have a feeling my way is not the shortest ... Since $_FILES['img']['tmp_name'] is without an extension, I aways use move_uploaded_file() to put back the original name incl extension (and unfortunately move the file) $somepage->image->add("new/path/image.jpg") then I have to delete the image from step 1 I am sure there is an easier way? Thanks, Lars Link to comment Share on other sites More sharing options...
ryan Posted December 7, 2012 Share Posted December 7, 2012 ProcessWire has a class called WireUpload that's worth checking out. 1 Link to comment Share on other sites More sharing options...
Soma Posted December 7, 2012 Share Posted December 7, 2012 Maybe also want to read this thread about uploading images via front end form. Link to comment Share on other sites More sharing options...
Lars282 Posted December 16, 2012 Author Share Posted December 16, 2012 (edited) Thanks guys! For potential privacy issues, I want to randomise the filename, ie not keep the original one. If I use setTargetFilename(), with timestamp and extension from pathinfo(), as well as setOverwrite(false), will PW append numbers to avoid override? EDIT: And is there a simple way of dealing with multiple uploads in the same way? Edited December 16, 2012 by Lars282 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now