Hi Arvind, Better add the member id number at the end of the file like member_10.jpg Thanks & Regards Udayakumar Sarangapani Sr. PHP Developer CompIndia Infotech Pvt. Ltd. Chennai. "Science is nothing but logic..." ________________________________ From: arvindsri123 <arvindsri123@xxxxxxxxx> To: php-objects@xxxxxxxxxxxxxxx Sent: Friday, 2 January, 2009 12:13:40 PM Subject: Re: Save image name by user id Hello, yes I need to know how to upload the files without overwriting existing ones, and in my case want add member id just before the original file name. like if a member has a id 10 so file name should be like "10_filename. jpg" in uploaded folder as well as in database. Thanks, Avi --- In php-objects@ yahoogroups. com, "Joe Forsythe" <jforsythe@. ..> wrote: > > I'm not exactly clear on what you're asking here. It sounds like you need > to know how to upload the files without overwriting existing ones. Is that > correct? If so, the function you're looking for is file_exists( ) combined > with a bit of recursion. Something like this should get you there: > $file_name = 'Your_file_name' ; > $file_ext = '.jpg'; > $full_file_name = $file_name.$ file_ext; > $foo = 1; > while (file_exists( $full_file_ name)) { > $full_file_name = $file_name.$ foo.$file_ ext; > $foo++; > } > > -- > Joe > > > Hello, > > > > I need help to upload image with member id, like "m_id_filename. jpg" > > just not to overwrite file. > > > > This is the path, and i m sending m_id on image upload page..on this > > page i am uploading 12 images, and i want to save every image with > > m_id number, Ex:m_id_imagename. jpg > > > > http://localhost/ sexyjobsmp/ upload_photos. php?m_id= 12 > > > > folder name is "uploads" on which i m uploading images. > > > > here is the code for single image upload... > > > > > > > > if (is_uploaded_ file ($_FILES['image_ 1']['tmp_ name'])) { > > if (move_uploaded_ file($_FILES[ 'image_1' ]['tmp_name' ], > > "uploads/{$_ FILES['image_ 1']['name' ]}")) { // Move the file over. > > > > echo '<p>The file has been uploaded!</p> '; > > > > } else { // Couldn't move the file over. > > echo '<p><font color="red"> The before image could not be > > moved.</font> </p>'; > > $image_1 = ''; > > } > > $image_1 = $_FILES['image_ 1']['name' ]; > > } else { > > $image_1 = ''; > > } > > > > Please help me wth it...if possible modify the same code so it will be > > easy for me. > > > > Thank you so much! > > Avi > > > > > Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/ [Non-text portions of this message have been removed]