Hello!

I'm building an app that allows users to upload images. Everything is working fine but I want to prevent a user from uploading an image twice as the duplicate gets moved to the tmp file and just sits there. Obviously this could become a problem. I tried this but duplicate images still get moved to the tmp folder and I don't understand why.

$uploaddir = 'C:/Program_Files/tmp/';
	   $order_dir_path = 'C:/Program_Files/www/online_photos/images/'; 
	   $order_dir = $order_dir_path .'ORDER #'.$order_number.'/';
	   $perm_dir = $order_dir . $filename;
	   $uploadfile = $uploaddir . $filename;
if     (!(file_exists($perm_dir)))   { 
   	   $uploadfile = $uploaddir . $filename;
	   (move_uploaded_file($_FILES[$i]['tmp_name'], $uploadfile));
	   		 if (!(file_exists($order_dir))){
			 mkdir($order_dir, 0777);
			}
if     (file_exists($uploadfile)&&(!$_FILES[$i]['name'] == '')){
			if (!(file_exists($order_dir))){
			rename($uploadfile,$perm_dir);
		}

Many thanks! Chris

    When you upload a file, a temp file is automatically made, that way the server can work with it. If you want to remove it, just delete the file $_FILES[$i]['tmp_name']....

      Write a Reply...