2
我想用uploadify發送一個額外的字段,我不能用後面的代碼獲得後端php文件的字段值。有人可以看到我的HTML和js代碼是否正確? 感謝用uploadify發送額外的字段數據
<script type="text/javascript">
$(document).ready(function() {
$("#fileUpload").fileUpload({
'uploader': 'uploadify/uploader.swf',
'cancelImg': 'uploadify/cancel.png',
'script': 'uploadify/upload.php',
'folder': 'files',
'multi': false,
'displayData': 'speed',
'scriptData': {'name':'', 'location':''},
'onSelectOnce' : function(event,data) {
$("#fileUpload").uploadifySettings('scriptData', {'name' : $('#name').val()});
}
});
});
</script>
HTML:
<h2>Single File Upload</h2>
<p>Display speed</p>
Name: <input name="name" id="name" type="text" maxlength="255" size="50" />
<div id="fileUpload">You have a problem with your javascript</div>
<a href="javascript:$('#fileUpload').fileUploadStart()">Start Upload</a> | <a href="javascript:$('#fileUpload').fileUploadClearQueue()">Clear Queue</a>
upload.php的
$name = $_GET['name'];
你調試過onSelectOnce()調用嗎?你是否100%確定這些值實際上正在設置? (例如使用`alert()`或`console.log()`測試輸出) – 2011-02-18 16:39:26