jQuery Uploadify HTTP error (ошибка HTTP: 302) - PullRequest
0 голосов
/ 21 сентября 2011

Uploadify постоянно выдаёт мне «ошибку HTTP», и это начинает раздражать.

Вот как я вызываю uploadify:

$(document).ready( function() {
  $('#upload_image').uploadify({
    'uploader'  : '/templates/v2/uploadify/uploadify.swf',
    'script'    : '/userimages.php',
    'cancelImg' : '/templates/v2/images/cancel.png',
    'folder'    : '/images/uploads/1',
    'auto'      : true,
    'fileExt'   : '*.jpg;*.gif;*.png',
    'fileDesc'  : 'Image Files (.JPG, .GIF, .PNG)',
    'removeCompleted' : false,
    'buttonText' : 'Upload Image'
  });
});

<input id="upload_image" name="userfiles" type="file" />

PHP код:

if (!empty($_FILES)) {
$tempFile   = $_FILES['userfile']['tmp_name'];
$targetPath = '/home/emailsms/app/images/uploads/' . $_SESSION['uid'] . '/';
$targetFile = $targetPath . $_FILES['userfile']['name'];
move_uploaded_file($tempFile, $targetFile);
switch ($_FILES['userfile']['error']) {
    case 0:
        $msg = ""; // comment this out if you don't want a message to appear on success.
        break;
    case 1:
        $msg = "The file is bigger than this PHP installation allows";
        break;
    case 2:
        $msg = "The file is bigger than this form allows";
        break;
    case 3:
        $msg = "Only part of the file was uploaded";
        break;
    case 4:
        $msg = "No file was uploaded";
        break;
    case 6:
        $msg = "Missing a temporary folder";
        break;
    case 7:
        $msg = "Failed to write file to disk";
        break;
    case 8:
        $msg = "File upload stopped by extension";
        break;
    default:
        $msg = "unknown error " . $_FILES['userfile']['error'];
        break;
}

if ($msg) {
    $stringData = "Error: " . $_FILES['userfile']['error'] . " Error Info: " . $msg;
} else {
    $stringData = "1";
} 

echo $stringData;

PHP-код работает, когда я использую форму:

Отправьте этот файл:

Ответы [ 2 ]

1 голос
/ 21 сентября 2011

Вам не хватает } в конце файла, чтобы закрыть if (!empty($_FILES)) {

Может быть, использовать другую IDE?

0 голосов
/ 21 сентября 2011

Попробуйте поместить это в .htaccess

SecFilterEngine Off
SecFilterScanPOST Off

Попробуйте эту тему: Uploadify: показать сообщение об ошибке из ответа HTTP

...