Hi i wrote a code to upload 4 images. I wrote code and works fine for my need. I wrote some thing like this. file1,file2.... file4 as the names of file fields. and in the process.php page like this

if ($_FILES['file1']['name'] != '') {
//// file upload
}
then file 2
if ($_FILES['file2']['name'] != '') {
//// file upload
}
till file 4 
then add data into database;
then 
function error

if any error occur while uploading image then that call the function and leads to an error page....

And the problem is if one file got error while uploading then the user need to upload all of 4 photos again !!!!! The old photos will store in server as useless.
Is there is any idea to overcome this.
Please help me

Try this:

if (strlen($_FILES['file1']['name'])>0) {
//// file upload
}
if (strlen($_FILES['file2']['name'])>0) {
//// file upload
}

And in addition, you can't just name the files file1, file2, file3, file4 on the php side and have it differently in the html form. Make sure that in your html form you have the file fields called file1, file2, file3 and file4. Then you may use those names in the array.

Remember the name of the files getting uploaded , delete them if any of the upload fails.

Remember the name of the files getting uploaded , delete them if any of the upload fails.

If you are talking about temporary storage on the server php does that for you.

Remember the name of the files getting uploaded , delete them if any of the upload fails.

I did the deleting code but some problem.
My code is like this

unlink("share/name of file1")
... file 4
then
header ("post.php"); // again page to upload ...

But not working saying Cant change header .. headres are already send at line .... Something like this....
Please advice me the right code

This article has been dead for over six months. Start a new discussion instead.