Anyone used uploadify scriptData

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • samvb
    New Member
    • Oct 2006
    • 228

    Anyone used uploadify scriptData

    am having a lot of headache trying to pass values to upload.php

    I have tried various ways to pass one parameter but it is always empty in upload.php.

    I have seen the sample but I failed to get it right nor all the other tutorials outthere helped me out.

    here is the code i am using

    Code:
    $(document).ready(function() {
    	$("#UploadImages").fileUpload({
    	'uploader': '/erivoices/fbox/uploader.swf',
    		'cancelImg': '/erivoices/fbox/cancel.png',
    		'script': '/erivoices/fbox/upload.php',
    		'folder': '1502',
    		'multi': true,
    		'buttonText': 'Add Photos',
    		'checkScript': '/erivoices/fbox/check.php',
    		'displayData': 'percentage',
    		'scriptData': {'serah':1502},
    		'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
    		'simUploadLimit': 2,
    		
    		
    		onError: function (a, b, c, d) {
    if (d.status == 404)
    alert('Could not find upload script. Use a path relative to: '+'<?= getcwd() ?>');
    else if (d.type === "HTTP")
    alert('error '+d.type+": "+d.status);
    else if (d.type ==="File Size")
    alert(c.name+' '+d.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB');
    else
    alert('error '+d.type+": "+d.text);
    },
    	});
    });
    
    	
    		function startUpload(id){
    			
    $('#UploadImages').fileUploadSettings('scriptData',"serah="+id);
    //alert('&amp;name='+$('#name3').val()+'&amp;location='+$("#location").val());
    $('#UploadImages').fileUploadStart();
    }
    And in the body section, I am trying both:

    Code:
    <div id="UploadImages">Photo Uploader Error</div>
     <a href="javascript:startUpload(1502)">Start Upload</a>
    		<a href="javascript:$('#UploadImages').fileUploadStart()">Start Upload</a> |  <a href="javascript:$('#UploadImages').fileUploadClearQueue()">Clear Queue</a></p>
       </div>
    I am having to Start Upload commands because I want to try them both but both failed. By the way, even the following variable don't go to upload.php

    Code:
    'folder': '1502',
    and upload.php is

    Code:
    <?php
    require('../konfig.php');
    // JQuery File Upload Plugin v1.4.1 by RonnieSan - (C)2009 Ronnie Garcia
    //I want to upload the files to folder 1502 which I must get from GET or POST as it varies from call to call.
    if (!empty($_FILES)) {
    require(DB);
    $workingon=mysql_real_escape_string($_POST[serah]);
    	$tempFile = $_FILES['Filedata']['tmp_name'];
    	
    	$targetPath = GROUPPICTURES.$workingon."/";
    //WHERE GROUPPICTURES is a constant defined in konfig.php
    
    	$targetFile =  str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
    	
    	// Uncomment the following line if you want to make the directory if it doesn't exist
    	// mkdir(str_replace('//','/',$targetPath), 0755, true);
    	
    	move_uploaded_file($tempFile,$targetFile);
    	
    	
    }
    	
    echo '1';
    
    ?>
    Last edited by Niheel; Dec 21 '10, 07:59 PM. Reason: Next time please include your code in your question so expert doesn't have to ask you.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    First check that upload.php is working correctly. Echo out the POSTed variable values.

    Next, try out a working example from the uploadify samples following the examples exactly as coded. When you have that working, you can then adapt to your requirements.

    Comment

    • samvb
      New Member
      • Oct 2006
      • 228

      #3
      hi,

      i took the code from the samples in uploadfy. They would work if i want to place the images/files in the same directory as the whole uploadify files, just like in the samples. And upload.php is not accepting the POSTed variables which is the root of the problem. I think the variables are not been posted to it but I don't know why.

      Comment

      • wiseneuron
        New Member
        • May 2012
        • 1

        #4
        'method' : 'GET',
        'scriptData': {'serah':1502},

        add method parameter with 'GET' in the option. The default method type is 'POST'. I test it, it can pass scriptData to server.

        Comment

        Working...