views:

135

answers:

4
<script type="text/javascript">
$(document).ready(function() {
    $("#uploadify").uploadify({
     'uploader'       : 'scripts/uploadify.swf',
     'script'         : 'scripts/uploadify.php',
     'buttonImg'      : 'css/btn_browseFiles.png',
     'rollover'       : 'true',
     'wmode'          : 'transparent',
     'height'         : '26px',
     'width'          : '109px',
     'cancelImg'      : 'cancel.png',
     'folder'         : 'uploads',
     'queueID'        : 'fileQueue',
     'simUploadLimit' : '2',
     'auto'           : true,
     'multi'          : true,
     'onComplete'     : function(event, queueID, fileObj, response, data) {
     $('#filesUploaded').append('<li><strong>file:</strong>&nbsp;<a href='+fileObj.filePath+' target="_blank">'+fileName+'</a></li>');
}
    });
});
</script>

I want to get the "+fileName+" to echo in PHP so I can pass it in a contact form.

<?php $que = ""; ?>` fill in the blanks
<input type="hidden" name="" value="<?php echo($que); ?>">
+1  A: 

Besides doing the following, I don't know of a way to pass Javascript variables to PHP...

<script type="text/javascript>

location.href="thisPage.php?fileName=" + fileName;

</script>

And then you would use PHP to do:

<?PHP $que = $_GET["fileName"]; ?>
PF1
You can (and provably should) use POST instead of GET.
voyager
A: 

If you want to use the text in the filename variable, you will need to pass it to a server request somehow.

It can be done several ways:

  • cookie
  • getline variable/query string
  • post variable (put it in a form element)

If you just want to get it into a value on the current page, you should be able to use javascript to do it:

#('#id_of_element').val(filename);

This is assuming you are using jQuery.

MacAnthony
A: 

This looks like some sort of uploading flash component. If it is uploading the file to your server, then you should be able to intercept the request and work with it from there.

jeef3
A: 
$trigger('uploadifyComplete',ID,{
'name'             : event.currentTarget.name,
'filePath'         : getFolderPath() + '/' + event.currentTarget.name,
'size'             : event.currentTarget.size,
'creationDate'     : event.currentTarget.creationDate,
'modificationDate' : event.currentTarget.modificationDate,
'type'             : event.currentTarget.type
},

can you see these?so you can use fileObj.name to get file name.

Seatle