开发者

what code should be in upload.php for jquery swfupload?

开发者 https://www.devze.com 2023-02-13 06:00 出处:网络
I just started using the jquery swfupload plugin and I have everything working besides the upload part... I don\'t know what to put in the upload.php file.

I just started using the jquery swfupload plugin and I have everything working besides the upload part... I don't know what to put in the upload.php file.

I get the error: Alert: {"name":"","type":"","size":""}; File: mayday-parade.png

upload.php originally had the code:

$file = $_FILES['file'];
echo '{"name":"开发者_StackOverflow中文版'.$file['name'].'","type":"'.$file['type'].'","size":"'.$file['size'].'"}';

obviously this doesn't work but i added the following:

if (file_exists($_SERVER['DOCUMENT_ROOT'].'/band_photos/' . $_FILES["file"]["name"])) {
    echo 'file exists';
} else {
    $uploaddir = 'uploads/';
    $uploadfile = $uploaddir . basename($_FILES['file']['name']);
    if(move_uploaded_file($_FILES["file"]["tmp_name"], $uploadfile)) {              
        echo 'success';
} else {
    echo 'error';
}   
}

I can't seem to find out what i'm doing wrong. Can anyone help?


Have you changed the the file_post_name in SWFUpload's settings to "file"?

If not, $_FILES['file'] will not return anything, because the default-name is Filedata , so use $_FILES['Filedata'] instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消