I have been searching for two days to find a solution which will let me upload employee image and rename it, I couldn't find any. Turns out it's pretty simple, I have to just pass the filename as query string and do a little modification in uploadify.php file.
- Passing the filename as part of the query string - followed by '?' mark include the filename with the paramater 'script'
'script' : 'uploadify/uploadify.php?name=imagename'
//don't worry about the extension - Modify the following line
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
with this
if(isset($_GET['name'])){ $targetFile = str_replace('//','/',$targetPath) . $_GET['name']. substr($_FILES['Filedata']['name'],-4); } else{ $targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name']; }
thanks for you for this solution you help me.
ReplyDeleteYou are welcome :)
ReplyDeleteI tried to follow what you were saying, but when I upload a file (or the uploader does) it doesn't give them the option of renaming the file.
ReplyDeleteIf that is not an option, is there a way to have the system automatically name the file with the uploaders IP address?
I had been struggling with this for several weeks. I had not contemplated adding a parameter to the "script". Silly really, works a treat. Thanks
ReplyDeleteThis is a good method, but if you are using onComplete after the file has been uploaded, it doesn't mention that the fileObj parameter in the callback contains the original filename. You need to use the response parameter instead.
ReplyDeletehttp://inglepingle.co.uk/2012/02/uploadify-how-to-rename-an-uploaded-file/
Thanks!
ReplyDeleteHere is the solution for the same, I posted on stackoverflow answers.
ReplyDeletehttp://stackoverflow.com/questions/10896715/rename-file-name-using-uploadify/16403822#16403822