2
Contributors
1
Reply
3
Views
10 Years
Discussion Span
Last Post by cmannering
0

You would create that segment of the form and then in the script which processes the date you need to have a variable which defines the target path.

Something like this for the form component:

<input type="hidden" name="userfilename" id="userfilename">
<span class="input_title">Choose a file to upload:</span>
<input name="uploadedfile" type="file" />

And then depending on what you are using to process that field you will need to specify the path and I recommend validating to make sure they can't upload certain extensions like executable which will destroy your database.

//$target_path = "uploads/";

// Where the file is going to be placed 
$target_path = 'C:/websites/uploads/'.$_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";
    print_r($_FILES);
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.