How I can validate input on form before upload file?

PHP upload script help!!!!!!!!!?

  • I'm making a file hosting site. my upload script is good, but one problem: if a file is uploaded, and an already uploaded file has the same name, the older file gets overwritten. Could I make it so it will return an error and not let you upload it? my upload from (html) <form enctype="multipart/form-data" action="upload.php" method="POST"> Please choose a file: <input name="uploaded" type="file" /> <input type="submit" value="Upload" /> </form> my php script <?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; if(move_uploaded_file($_FILES['uploaded'… $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded. "; echo "your url is tylersfiles.netne.net/fileup/upload/(you… ". basename( $_FILES['uploadedfile']['name']). " ."; } else { echo "Sorry, there was a problem uploading your file."; } ?> <html> <FORM> <INPUT TYPE="BUTTON" VALUE="Home Page" ONCLICK="window.location.href='http://ty… </FORM>

  • Answer:

Tyler at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Marked this for later viewing.

tedead

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.