I have this code to take care of my files I upload on my server. But sometimes files get skipped and won't upload. How can I in that case retry the script to give the file a new shot? move_uploaded_file($_FILES['Filedata']['tmp_name'], "../media/uploads/". $myVariable. ".jpg"); PHP:
Your best bet is to simply check if the file exists, and then redirect them back to the upload page if it failed. this should do the trick if (file_exists($_FILES['Filedata']['tmp_name'])){ move_uploaded_file($_FILES['Filedata']['tmp_name'], "../media/uploads/".$myVariable. ".jpg"); } else { header('location: upload.php'); exit(); } PHP: