私のコードがあります:
$('#file_upload').uploadify({
'swf' : 'uploadify.swf',
'uploader' : 'uploadify.php',
'onSelect' : function(file) {
$('#start').removeClass('hidden');
},
'method' : 'post',
'formData' : {
'to': $('input#to').val(),
'from': $('input#from').val(),
'subject': $('input#subject').val()
},
'onQueueComplete' : function(queueData) {
window.location.replace("index.php?success=uploaded");
},
'onUploadSuccess' : function(file, data, response) {
alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
}
// Your options here
});
ご覧のとおり、TO、FROM、SUBJECT の 3 つのパラメーターを POST メソッドで送信しています。
サーバースクリプトあり
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (move_uploaded_file($tempFile, $targetFile)) {
echo $_REQUEST['subject'];
} else {
echo "Something wrong";
}
}
echo $_REQUEST['subject']; 何も返さない私の間違いはどこですか?
たとえば、 'subject': $('input#subject').val() を 'subject': 'test subject' に変更すると、機能します。しかし、入力から値を送信する必要があります。どうすればそれができますか?
ありがとう