Hi Joe & Udaya Kumar, I have done it, and its working fine, Thanks a lot both of you. Thanks, Avi --- In php-objects@xxxxxxxxxxxxxxx, Joe Forsythe <jforsythe@...> wrote: > > Hi Avi, > > 3 points: > > 1. You can do as Udayakumar has suggested or I suggest. Putting the > member id at the end of the file name or the front is a "half a dozen > of one, six of the other" sort of thing. > > 2. I already provided your answer, short of writing three or four > paragraphs explaining what everything does, dropping it into a > function, and adding the function to your code. If anything in this > code doesn't make sense, please let us know what and I or someone > else will be happy to illuminate it for you. > > > > $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++; > > > } > > 3. If you are looking for something besides a helping hand, a bit of > tutoring, help debugging, code ideas, efficiency thoughts, opinions, > etc (i.e. someone to do your work for you), might I suggest this > website? http://www.rentacoder.com/ . > > -- > Joe > > > 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..." > > On Jan 2, 2009, at 12:43 AM, arvindsri123 wrote: > > > 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@xxxxxxxxxxxxxxx, "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 > > > > > > > > > > > > > > > > > > > > > [Non-text portions of this message have been removed] >