Php文件没有上传到文件夹

时间:2013-02-25 06:23:07

标签: php

我有一个html上传表单。它在我的Localhost中工作。但它不适用于直播服务器。它将信息插入数据库,但不将文件上传到名为“photos”的文件夹

Php代码:

$upload_path = "photos/";
$upload = mysql_query("INSERT INTO photos (photo_cap, photo_name, photo, date) 
VALUES('$title','$filenameuniq', '$file', '$uploadate')");

        if($upload)
        {                       
            if(!empty($file))
            {
                if(!move_uploaded_file($_FILES['file']['tmp_name'], $upload_path . $filenameuniq))
                {
                echo '<pre>Your file was not uploaded please try again here are your debug informations:'.print_r($_FILES) .'</pre>';                   
                }                   
            }//// upload to folder  

            echo "<font color=green>Successfully Updated.</font>";
            header("Refresh:2; url=allphotos.php");
            exit(); 
        }

调试:

Array ( [file] => Array ( [name] => Blue hills.jpg [type] => image/jpeg [tmp_name] => 
C:\Windows\Temp\php95FB.tmp [error] => 0 [size] => 28521 ) )

Your file was not uploaded please try again here are your debug informations:1

为什么不上传到“照片”文件夹?在服务器上如何显示C:\ Windows?

2 个答案:

答案 0 :(得分:1)

我认为问题在于最大文件大小

Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.

在php.ini中将值更改为更高的值.safer方法是将最大上载大小限制为2mb

答案 1 :(得分:0)

对尺寸和类型进行验证。然后检查..