Hayageek jQuery file upload plugin pass extra data to PHP -
i using excellent hayageek file upload plugin, progress bar.
the plugin allows 1 specify url of php file processes uploaded file(s), this:
var uploadobj = $("#fileuploader").uploadfile({ url: "uploader.php", method: "post", allowedtypes:"jpg", //,png,gif,doc,pdf,zip filename: "myfile", multiple: false, autosubmit: true, showstatusaftersuccess:false, onsuccess:function(files,data,xhr) { alert( data ); }, });
i wish send (to php side) item id along uploaded file. advanced
tab on ravi's website (click advanced manually) shows possible send information php upload processor file using either:
formdata: {"name":"ravi","age":31},
or, dynamic info:
dynamicformdata: function() { var data ={ location:"india"} return data; },
i not clear on difference between 2 (how use differently) -- not able send dynamic data via ordinary formdata:
parameter if using variable, such formdata: {"name": strname,"age": intage},
?
anyway, real problem next point: there no information how retrieve information on php side. assume data sent via json. i'm crap @ json.
here's tried - these attempts did not work (attempting alert in success:
function, alert(data)
:
php:
$formdat = json_decode($_post['formdata']); echo $formdat.name;
nor this:
$formdat = $_post['formdata']; echo $formdat['name'];
how should reference formdata - example, name
or age
values?
the answer simple didn't think try it. 3 examples in original question above:
$n = $_post['name']; $age = $_post['age'];
and
$n = $_post['location']; echo $n; //alerts india
source: response thread in disqus comment section on author's website:
how access dynamicformdata in upload.php ?? suresh koduri rafael says: ** in javascript: ** dynamicformdata: function() { var data ={ location:"india"} return data; } ------------------------------------- ** in upload.php ** $location = $_post["location"];
Comments
Post a Comment