1
votes

With a successful upload from the blueimp fileupload plugin, the forms other data is submitted as well, however, the json data response I'm receiving from Firebug shows response to each input field is truncated to just one character (byte?). Is this the expected response? I am using jQueryMobile and Blueimp fileupload plugin. Please see specifics:

var formData = $('#uploadform'); console.log( formData.serializeArray() );

Result from console.log
[Object { name="image_name", value="Don"}, Object { name="image_description", value="Testing"}, Object { name="image_keywords", value="Musician Actor Artists"}, Object { name="image_nudity", value="0"}, Object { name="cat_id", value="42"}, Object { name="action", value="uploadimage"}]

POST Response from blueimp fileuploadsubmit

{"files":[{"name":"image2.jpeg","size":114688,"type":"image/jpeg","cat_id":"4","image_name":"D","image_nudity":"","image_description":"T","image_keywords":"M","action":"u","example":"","user_id":"2","url":"../models/data/tmp_media/image2.jpeg","thumbnailUrl":"../models/data/tmp_media/thumbnail/image2.jpeg","deleteUrl":"http://myfame/mobile/?file=image2.jpeg","deleteType":"DELETE"}]}

Here's the code from UploadHandler.php

protected function handle_form_data($file, $index) {
    global $user_info;
    $file->cat_id = (empty($_REQUEST['cat_id'][$index])) ? "" : $_REQUEST['cat_id'][$index];
    $file->image_name = (empty($_REQUEST['image_name'][$index])) ? "" : $_REQUEST['image_name'][$index];
    $file->image_nudity = (empty($_REQUEST['image_nudity'][$index])) ? "" : $_REQUEST['image_nudity'][$index];
    $file->image_description = (empty($_REQUEST['image_description'][$index])) ? "" : $_REQUEST['image_description'][$index];
    $file->image_keywords = (empty($_REQUEST['image_keywords'][$index])) ? "" : $_REQUEST['image_keywords'][$index];
    $file->action = (empty($_REQUEST['action'][$index])) ? "" : $_REQUEST['action'][$index];
    $file->example = (empty($_REQUEST['example'][$index])) ? "" : $_REQUEST['example'][$index];
    $file->user_id = $user_info['user_id'];

Note the discrepancy of the submitted data and response truncating the inputs to one character, any ideas on how this can be fixed, or is this a bug?

2
OK SOLVED I changed all $_REQUEST to $_POST instead and that solved this particular problem. Sorry I couldn't answer my own POST not enough REP. - nightbreeze

2 Answers

0
votes

SOLVED - Change all $_REQUEST to $_POST or $_GET depending on what you chose as option and modify the function handle_form_data($file, $index) with your selected option. Best to check if the variables are empty as they throw an error if they are not set.

Doing this solved this particular problem.

0
votes

Changing from $_REQUEST to $_POST (inside handle_form_data function) does the trick.

protected function handle_form_data($file, $index) {
    ....
    $file->user = @$_POST['var1'][$index];
    .....
}

however also make sure that you have made your input variables as a array,

<input type="hidden" name="var1[]" value="try">