我的上传脚本由于某种原因不会上传

时间:2016-01-02 12:13:49

标签: php file-upload

我正在尝试上传图片文件,但它似乎无法使用此代码:

upload.php

server {
        listen       80;
        server_name  IP-Address;
        location / {
            root   /home/deploy/repos/application-name/public;
            passenger_enabled on;
            rails_env production;
            client_max_body_size 10M;
        }
    ......
}

img_form.html

<?php

$worked=1;
$file_up_size=$_FILES['img'][size];
if ($_FILES[img][size]>250000){
echo "Your file size is above 250KB please reduce it and re-upload it.<br>";
break;
$worked=0;
}

$img_name = $_FILES[img][name];
$img_dir = "uploads/$img_name";

if($worked == 1){

if(move_uploaded_file ($_FILES[img][tmp_name], $img_dir)){
}
else {
    echo "WARNING: File upload failed!";
    break;
}

}
?>

1 个答案:

答案 0 :(得分:0)

代码适用于任何普通网站主机,但我的vps在php.ini中有一些小狗设置,我仍然不知道但至少脚本有效!