April 8, 201115 yr 0 down vote favorite Hi, I'm using Meioupload on a website built with CakePHP, and it is working fine for having multiple upload fields. The problem I have now is that if person A uploads a picture called 'me.jpg' and then person B uploads a picture called 'me.jpg', person B's will overwrite the first upload. Is there a way in Meioupload to change the filename as the picture is uploaded? E.g. add the person's username to the start so it would look like 'persona_me.jpg' and 'personb_me.jpg'? This is the code I currently have: var $actsAs = array('MeioUpload' => array( 'picture' => array( 'dir' => 'files/device_images', 'create_directory' => true, 'allowed_mime' => array('image/jpeg', 'image/pjpeg', 'image/gif', 'image/png'), 'allowed_ext' => array('.jpg', '.jpeg', '.png', '.gif'), 'thumbsizes' => array( 'small' => array('width'=>100, 'height'=>100), 'medium' => array('width'=>240, 'height'=>180), 'large' => array('width'=>640, 'height'=>480) ))); Thanks for any help
April 8, 201115 yr you could try adding a timestamp or something so that each image uploaded is unique PM me if you need any help
April 8, 201115 yr could use a database to get the next unique number to add on the end of an uploaded image so that even if the same user uploads an image called me.jpg but its a different one then they dont get rid of their old me.jpg that they may want. where is the part of the script that names the images or carries the name through of the original image to save onto the server? other than that, like the above said you could use a timestamp, you could make the variable to change the name something like $imagename = "'$originalname'.'time()'.'$extension'"; something similar to that should do the job
April 8, 201115 yr Or u could use the rename() function this is specifically made for renaming files and directories rename($oldfilename,$newfilename.$extension); Edited April 8, 201115 yr by webdesigner93
Create an account or sign in to comment