このスクリプトに問題があります。ヘッダー リダイレクトは呼び出されませんが、MySQL クエリは呼び出されます。
MySQLクエリが呼び出され、ヘッダーが呼び出されないので、私には奇妙に見えますか?
リダイレクトする PHP スクリプト:
if (array_key_exists('pic',$_FILES) && $_FILES['pic']['error'] == 0 ) {
$pic = $_FILES['pic'];
if (!in_array(get_extension($pic['name']),$allowed_ext)) {
exit_status('Only '.implode(',',$allowed_ext).' files are allowed!');
}
// Move the uploaded file from the temporary
// directory to the uploads folder:
if (move_uploaded_file($pic['tmp_name'], $upload_dir.$key.'-'.$pic['name'])) {
$name = $key.'-'.$pic['name'];
$query = "INSERT INTO `uploads` (id, file_name, up_date, rm_date) VALUES ('$id', '$name', '$up_date', '$rm_date')";
mysql_query($query) or die(mysql_error()); // **Get called**
header("Location: download.php?id=$id"); // **Does not get called**
exit();
}
}
そしてPHPスクリプトを呼び出すJavascript
$(function(){
var dropbox = $('#dropbox'),
message = $('.message', dropbox);
dropbox.filedrop({
// The name of the $_FILES entry:
paramname:'pic',
maxfiles: 1,
maxfilesize: 25,
url: 'upload.php',
uploadFinished:function(i,file,response){
$.data(file).addClass('done');
// response is the JSON object that upload.php returns
},
error: function(err, file) {
switch(err) {
case 'BrowserNotSupported':
showMessage('Your browser does not support HTML5 file uploads!');
break;
case 'TooManyFiles':
alert('Too many files! Only one at same time is allowed.');
break;
case 'FileTooLarge':
alert(file.name+' is too large! Please upload files up to 25mb.');
break;
default:
break;
}
},
// Called before each upload is started
beforeEach: function(file) {
if(!file.type.match(/^image\//)) {
alert('Only images are allowed!');
// Returning false will cause the
// file to be rejected
return false;
}
}
});
});