JQuery Upload File from Dialog window
I try to upload file from Dialog (JQuery UI) window like:
$( ".selector" ).dialog( "option", "buttons", [{ text: "Upload", click: function()
{ $( ".selector" ). append('<form action="../test/test_upload.php"
method="POST" name="getnamefile">
<input type="file" id="uploadfile" name="uploadfile">
<input type="submit" id="Submit" name= "Submit" value="Upload"></form>'); }....
and on php parth:
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
$upfl = $_POST['uploadfile'];
$target_path = "../tmp/";
//if(is_uploaded_file($_FILES['uploadfile']['tmp_name']))
if(move_uploaded_file($_FILES['uploadfile']['tmp_name'], $target_path.$_FILES['uploadfile']['name'])) {
echo "The file ". basename( $_FILES['uploadfile']['name'])." has been uploaded";
} else{
echo $_FILES['uploadfile']['tmp_name'];
echo "There was an error uploading the file";
}
Always receive err开发者_如何学JAVAor "There was an error uploading the file" If use 2 file html and the same php - all work ok. What be the reason? It seems that all identical. Thanks.
Try adding enctype="multipart/form-data"
attribute to your form.
精彩评论