Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Valums" file uploader and method POST

My problem is that the file-uploader http://valums.com/ajax-upload/ adds params to the URL instead of passing them by POST.

For example:

action:'/upload.php'
params : { x1:'x1'}

... will submit as the URL:

/upload.php?x1=x1

(GET), but I need to pass additional params by POST. Is this possible?

like image 792
kusanagi Avatar asked Feb 28 '11 15:02

kusanagi


1 Answers

I think you're using an old version of ajax-upload. I found this new one.

Here's an example of it working OK with a data attribute properly converted to hidden input fields: http://jsfiddle.net/marcosfromero/XkCP5/

var button = $('#button1'), interval;
new AjaxUpload(button,{
    //action: 'upload-test.php', // I disabled uploads in this example for security reasons
    action: 'upload.htm', 
--> data: {field1: 'value1', field2: 'value2'}, <--
    ...

I stopped the submission of the file and got this automatically created form:

<form enctype="multipart/form-data" method="post" style="display: none;" action="upload.htm" target="ValumsAjaxUpload0">
    <input type="hidden" name="field1" value="value1">
    <input type="hidden" name="field2" value="value2">
    <input type="file" name="myfile" style="position: absolute; margin: -5px 0pt 0pt -175px; padding: 0pt; width: 220px; height: 30px; font-size: 14px; opacity: 0; cursor: pointer; display: block; z-index: 2147483583; top: 48px; left: 147px;">
</form>
like image 145
marcosfromero Avatar answered Nov 12 '22 03:11

marcosfromero