【问题标题】:PHP Uploading a image to a serverPHP 将图像上传到服务器
【发布时间】:2014-03-23 05:35:34
【问题描述】:

我做了一个上传系统,我在我的电脑上测试它,使用localhost xampp 服务器,它工作正常,但我把它移到主机上,我收到了这个错误:

PHP Warning:  Unknown: open_basedir restriction in effect. File(C:\Windows\TEMP) is not within the allowed path(s): (E:\Domains\site.com) in Unknown on line 0
PHP Warning:  File upload error - unable to create a temporary file in Unknown on line 0
PHP Warning:  file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in E:\Domains\site.com\wwwroot\admin\addexec.php on line 12
PHP Warning:  getimagesize() [<a href='function.getimagesize'>function.getimagesize</a>]: Filename cannot be empty in E:\Domains\site.com\wwwroot\admin\addexec.php on line 14

以下是文件:

addexec.php

<?php

    include('connect.php');

        if (!isset($_FILES['image']['tmp_name'])) {
        echo "";
        }else{
        $file=$_FILES['image']['tmp_name'];
        $image= addslashes(file_get_contents($_FILES['image']['tmp_name']));
        $image_name= addslashes($_FILES['image']['name']);
        $image_size= getimagesize($_FILES['image']['tmp_name']);


            if ($image_size==FALSE) {

                echo "That's not an image!";

            }else{

                move_uploaded_file($_FILES["image"]["tmp_name"],"../reservation/img/products/" . $_FILES["image"]["name"]);

                $location=$_FILES["image"]["name"];
                $pname=$_POST['pname'];
                $desc=$_POST['desc'];
                $price=$_POST['price'];
                $cat=$_POST['cat'];



                $update=mysql_query("INSERT INTO products (imgUrl, product, Description, Price, Category)
    VALUES
    ('$location','$pname','$desc','$price','$cat')");
    header("location: products.php");
                exit();

                }
        }
    ?>

我不知道如何准确设置临时文件夹,我需要一些帮助来解决这个问题。我能做些什么?我已经将服务器上的权限设置为777,并关闭了php安全模式。

【问题讨论】:

标签: php image file upload temp


【解决方案1】:

;是否允许 HTTP 文件上传。

file_uploads=开启

; HTTP 上传文件的临时目录(如果没有,将使用系统默认值) ;指定)。

upload_tmp_dir="D:\xampp\tmp"

尝试更改 php.ini 中的上述位置可能对您有用。

【讨论】:

    猜你喜欢
    • 2013-11-02
    • 2014-02-13
    • 2011-02-02
    • 2015-03-29
    • 2011-10-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多