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 error "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.

Answers


Try adding enctype="multipart/form-data" attribute to your form.


Need Your Help

Why 2 different vocabularies for the same attribute in DBpedia?

sparql dbpedia

Why does DBpedia use multiple vocabularies for the same attributes?

Signal R Chat application on IIS not working

asp.net signalr

I am trying to build a SignalR application in Visual Studio 2012. My problem is that it works well under Visual Studio debug (using Visual Studio 2012 on Windows 7), but when I try to deploy the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.