ScriptData is not transmitted when there are multiple instances of uploadify

I have two options for adding to my form. Below you will find definitions.

And two buttons that start the download. The image button is the only one related to the question:

$( "#btnimageupload" ).button().click(function()
{
 $('#picbrowse').uploadifySettings( 'scriptData', ({ 'isSelected': $( '#selectImage' ).val() }));
 $('#picbrowse').uploadifyUpload();
});

Now here is the problem:

When I click the btnimageupload button, the image does not load. The progress bar goes to 100 and stops. No errors, javascript or otherwise.

But when I turn off the input window of the vdobrowse file and the corresponding script, everything works fine. Images are uploaded and data is transferred.

Here's the hard part ... if I don't pass scriptData in the btnimageupload click handler, the images will load even using the vdobrowse file input box on the page.

, scriptData , .

- , ?

$('#picbrowse').uploadify(
{
 uploader  : 'script/uplodify/uploadify.swf',
 script    : '../../dopost.php',
 cancelImg : 'script/uplodify/cancel.png',
 folder    : '/images',
 queueID   : 'picqueue',
 auto      : false,
 multi     : true,
 fileDesc    : 'Image Files',
 fileExt     : '*.gif;*.jpg;',
 queueSizeLimit: 5,
 scriptData:
 ({
  'action': 'upload_image',
 }),
 onComplete: function( event, queueID, fileObj, response, data )
 {
  console.log( reponse)
 }
});

.

$('#vdobrowse').uploadify(
{
 uploader  : 'script/uplodify/uploadify.swf',
 script    : '../../dopost.php',
 cancelImg : 'script/uplodify/cancel.png',
 folder    : '/video',
 queueID   : 'vdoqueue',
 auto      : false,
 multi     : true,
 fileDesc    : 'Video Files',
 fileExt     : '*.avi;*.mpg;*.mov;*.mp4;*.mpeg;*.flv;*.mkv;*.wmv',
 queueSizeLimit: 5,
 scriptData:
 {
  action: 'upload_video'
 },
 onComplete: function( event, queueID, fileObj, response, data )
 {
  console.log( response );
 }

});
+3
3

, , , , scriptData scriptData.

, . uploadifySettings . , .

, , , , , .

Forum

swfUpload. , . swfUpload , api uploadify api.

+1

, , , scriptData Uploadifys , scriptData dopost.php .

:

$fileParts  = pathinfo($_FILES['Filedata']['name']);
$extension = strtolower($fileParts['extension']);
switch($extension){
    case "gif" | "jpg":
        // Do Image Upload Action
    break;
    case "avi" | "mpg" | "mov" | "mp4" | "mpeg" | "flv" | "mkv" | "wmv":
        // Do Video Upload Action
    break;
}
+1

I get scripData just fine, I made an example on my website
I limited the upload size to 500 KB for obvious reasons and adjusted the code:

$('#picbrowse').uploadify(
{
    uploader  : 'uploadify.swf',
    script    : 'uploadify.php',
    cancelImg : 'cancel.png',
    folder    : 'uploads/images',
    queueID   : 'picqueue',
    auto      : false,
    multi     : true,
    removeCompleted : false,
    fileDesc    : 'Image Files',
    fileExt     : '*.gif;*.jpg',
    sizeLimit   : 512000,
    queueSizeLimit: 5,
    scriptData: {action: 'upload_image'},
    onComplete: function( event, queueID, fileObj, response, data )
    {
        $ul.html('');
        var json = jQuery.parseJSON(response);
        $.each(json,function(k,v){
            var li = "<li>"+k+": "+v+"</li>";
            $ul.append(li);
        });
    },
    onError: function (event,ID,fileObj,errorObj) {
        console.log(errorObj.type + ' Error: ' + errorObj.info);
    }
});

$('#vdobrowse').uploadify(
{
    uploader  : 'uploadify.swf',
    script    : 'uploadify.php',
    cancelImg : 'cancel.png',
    folder    : 'uploads/video',
    queueID   : 'vdoqueue',
    auto      : false,
    multi     : true,
    sizeLimit   : 512000,
    fileDesc    : 'Video Files',
    fileExt     : '*.avi;*.mpg;*.mov;*.mp4;*.mpeg;*.flv;*.mkv;*.wmv',
    queueSizeLimit: 5,
    scriptData: {action: 'upload_video'},
    onComplete: function( event, queueID, fileObj, response, data )
    {
        $ul.html('');
        var json = jQuery.parseJSON(response);
        $.each(json,function(k,v){
            var li = "<li>"+k+": "+v+"</li>";
            $ul.append(li);
        });
    }

});

And I use the standard uploadify.php file and instead repeat the POST variable:

echo json_encode($_POST);
+1
source

Source: https://habr.com/ru/post/1780414/


All Articles