I’m having a problem with $_FILES, I have a form which refreshs its self display all the data which was entered by the user, the user may unload one picture for there profile on submit click the picture uploads fine and is stored into a folder the problem I have is that if the user presses the f5 the fresh button the picture is added again to the folder, what i would like to know is there a way of stopping this, I have been working with some code and nothing seems to work
What you mean? Do you mean you worked successfully to upload the file via AJAX? It is not easy to upload the files with AJAX. So better and safe way to upload the files would be to use the page reloading and do what Jake has already suggested. If you don’t want to create multiple pages then you can even manage everything in a single file too:
Suppose your file is upload.php:
<?hp
if($_SERVER['REQUEST_METHOD'] == 'POST'){
// do upload the file
// redirect the same page upload.php
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="Raju Gautam" />
<title>Untitled 1</title>
</head>
<body>
<form method="post" action="upload.php" name="frm1">
// your form goes here....
</form>
</body>
</html>
Thanks i was thinking of something on those lines, out of interest can i do something with AJAX to solve this problem, has i have just got my first AJAX script working today.