PHP File Upload

/ Published in: PHP
Save to your folder(s)

Just a simple piece of code to store an uploaded file in PHP.

Copy this code and paste it in your HTML
  1. $target_path = "uploads/";
  2. $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
  4. if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
  5. echo "The file ". basename( $_FILES['uploadedfile']['name'])." has been uploaded";
  6. } else{
  7. echo "There was an error uploading the file, please try again!";
  8. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.