在Ubuntu 16.04 LTS上设置LAMP后,Php无法看到上传的文件

时间:2016-11-20 14:44:18

标签: php ubuntu ubuntu-16.04

我已经在Linode上成功安装了带LAMP的ubuntu。在此之前,我所有的网站都是在godaddy中托管的。一切正常,以及使用XAMPP的Localhost。

然而,有了这台新服务器@Linode;在我将所有PHP文件上传到服务器然后开始上传产品之后;

已插入mysql,但我的abc.com/img文件夹为空!!!

require "../db/order.php";
$order=new order();

$allowed=['image/jpeg','image/png','image/gif'];

if(empty($_FILES['photos']['name'][0])){

    echo "<h1>plz select photos</h1>";

}else{

    foreach ($_FILES['photos']['type'] as $abc){

        if(!in_array($abc,$allowed)){
            echo '
            <div style="    margin: auto;
                width: 60%;
                border: 1px solid #ff0000;
                padding: 10px;">
            ';          

            echo '<p><a href="upload_picture.php">back to upload</a></p>';
            echo '</div>';

            $check=false;
        }else{
            $check=true;
        }
    }

    if($check==true){

        $path = "../../img/"; 
        for($i=0;$i<count($_FILES['photos']['name']);$i++){
            move_uploaded_file($_FILES['photos']['tmp_name'][$i],iconv("utf-8", "cp936", $path.$_FILES['photos']['name'][$i]));
            $img_name[]=$_FILES['photos']['name'][$i];
        }

        $order->add_img($img_name);

    }
}

的php.ini

我已经改变了

;upload_tmp_dir

upload_tmp_dir =/tmp

但它仍然无效。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

您的文件可能没有上传的原因有多种。

首先,我建议在# Select the pandas.Series object you want >>> df['text'] 0 vendor a::ProductA 1 vendor b::ProductA 2 vendor a::Productb Name: text, dtype: object # using pandas.Series.str allows us to implement "normal" string methods # (like split) on a Series >>> df['text'].str <pandas.core.strings.StringMethods object at 0x110af4e48> # Now we can use the split method to split on our '::' string. You'll see that # a Series of lists is returned (just like what you'd see outside of pandas) >>> df['text'].str.split('::') 0 [vendor a, ProductA] 1 [vendor b, ProductA] 2 [vendor a, Productb] Name: text, dtype: object # using the pandas.Series.str method, again, we will be able to index through # the lists returned in the previous step >>> df['text'].str.split('::').str <pandas.core.strings.StringMethods object at 0x110b254a8> # now we can grab the first item in each list above for our desired output >>> df['text'].str.split('::').str[0] 0 vendor a 1 vendor b 2 vendor a Name: text, dtype: object 之前使用is_uploaded_file()来查看您的文件是否真正到达服务器。

move_uploaded_file()

您的HTML表单标记上有if (is_uploaded_file($_FILES['photos']['tmp_name'][$i])) { // move the file } else { echo 'file not uploaded'; } 吗?

php.ini中有enctype="multipart/form-data"吗?

file_uploads = On怎么样?