Posted By

suibhne on 11/28/09


Tagged

php upload


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

joacoleo
xmartyxcorex
Blacksnipe
tapdrup


PHP File Upload


 / Published in: PHP
 

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

  1. $target_path = "uploads/";
  2. $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
  3.  
  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  

You need to login to post a comment.