Jump to content

Recommended Posts

Posted

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

  1. move_uploaded_file() to put back the original name incl extension (and unfortunately move the file)
  2. $somepage->image->add("new/path/image.jpg")
  3. then I have to delete the image from step 1

I am sure there is an easier way?

Thanks,

Lars

  • 2 weeks later...
Posted (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 by Lars282

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...