Jump to content

PHP Upload Csv File


travelkind

Recommended Posts

I am trying to create an area (in a webpage) where someone can upload a file directly to my server.  I am getting an error that says:

 

// Where the file is going to be placed $target_path = "/html/beer/uploads/"; /* Add the original filename to our target path. Result is "/html/beer/uploads/filename.csv" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $target_path = "/html/beer/uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; }

 

I can't figure out where the error in my code is:

 

// Where the file is going to be placed

$target_path = "/html/beer/uploads/";

 

/* Add the original filename to our target path. 

Result is "/html/beer/uploads/filename.csv" */

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

 

 

$target_path = "/html/beer/uploads/";

 

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {

    echo "The file ".  basename( $_FILES['uploadedfile']['name']).

    " has been uploaded";

} else{

    echo "There was an error uploading the file, please try again!";

}

 

Maybe there is an easier way to do this?  Any help would be appreciated.

 

Link to comment
https://forums.phpfreaks.com/topic/182328-php-upload-csv-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.