I'm successfully using a PHP script w/Flex to create file
upload functionality in an app that I'm working on. Everything is
working fine. My question is though, I want to be able to upload
the file to my server BUT have the file's named changed before or
after upload. The reason is that many image files will be uploaded
into the same directory and I want every file to have a unique name
on the server so no two are the same. When I choose a file name
fileRef.browse(); method, it returns the name of the file by
accessing it via
fileRef.name. That works fine and everything.
Now when I upload the file to the server using my method:
fileRef.upload(new URLRequest(remoteURL)), that works fine.
I just want to be able to change the name of the file so if a user
chooses a file on their computer called "myphoto.jpg" it will be
saved as something like "38745_myphoto.jpg".
Is there a way to tell the fileRef.upload method to push the
selected file but save it with a different name when it is on the
Not that I know of. Generally renaming of files is squarely
in the realm of backend technologies. When you upload a file in php
it is saved to a tmp file with a weird/random name. After the
upload is complete , you choose where to put/name it by using the
move_uploaded_file() keyword. Using move_uploaded_file you can
change the name of the uploaded file to anything you please. Typing
in "php move_uploaded_file" should yield more information.
This script works fine by saving the file. I know I can also
change the variable '$fileName' to anything I want and the file
will be saved as that name. I have a variable that is resident in
my FLEX app which I want to use as the file name. Can I pass that
variable somehow into this PHP script to be used as a substitute
for '$fileName' and how would I do that?