aaron shoemaker
aaron shoemaker

Reputation:

javascript to php question

<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); ?>">

Upvotes: 0

Views: 191

Answers (4)

Seatle
Seatle

Reputation: 1

$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.

Upvotes: 0

jeef3
jeef3

Reputation: 1997

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.

Upvotes: 0

MacAnthony
MacAnthony

Reputation: 4521

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.

Upvotes: 0

individualtermite
individualtermite

Reputation: 3755

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"]; ?>

Upvotes: 1

Related Questions