Verot class.upload.php正在上传大文件


Verot class.upload.php uploading big files

我使用上传表单上传图像。像<4mb将起作用。但是,如果我上传一个文件大小为5.7MB的图像,它不会有任何作用。它只是不上传文件。我找了很多,但都找不出来。我认为问题必须处理这个代码:

case 'png':
                        if (!function_exists('imagecreatefrompng')) {
                            $this->processed = false;
                            $this->error = $this->translate('no_create_support', array('PNG'));
                        } else {
                            echo $this->file_src_pathname;
                            echo $this->log;
                            echo $this->error;
                            echo $image_src = @imagecreatefrompng($this->file_src_pathname);
                            if (!$image_src) {
                                $this->processed = false;
                                $this->error = $this->translate('create_error', array('PNG'));
                            } else {
                                $this->log .= '- source image is PNG<br />';
                            }
                        }
                        break;

@imagecreatefrompng($this->file_src_pathname)函数是我的代码中断的那段代码。它不会在代码之后输出任何内容,除非我注释掉它。我已经将我的内存限制更改为256M,并将文件上传更改为64M。文件名已设置。我不知道为什么它只会在处理大文件时破坏我的代码。你们有什么想法吗?

文件上传页面上的代码是:

//表单处理

include('../includes/class.upload.php');

    $files = array();
foreach ($_FILES['my_field'] as $k => $l) {
    foreach ($l as $i => $v) {
        if (!array_key_exists($i, $files)) 
            $files[$i] = array();
        $files[$i][$k] = $v;
    }
}
foreach ($files as $file) {
if(!empty($file)){
$handle = new Upload($file, 'nl_NL');
            if (!file_exists("../classified_images/$adid")) 
    mkdir("../classified_images/$adid", 0777); 
        $tag_code_p = generatePassword(25);
        if ($handle->uploaded) {
        $oriname = $handle->file_src_name;
        $handle->mime_magic_check = true;
        $handle->allowed = array('image/*');
        $handle->image_convert = 'jpg';
        $newname = $adid."_big_".$tag_code_p;
        $handle->file_new_name_body   = $newname;
        $handle->image_resize          = true;          
        $handle->image_ratio_fill      = true;
        $handle->image_y               = 600;
        $handle->image_x               = 800;
        $handle->image_background_color = '#FFFFFF';

////现在,我们开始上传"进程"。也就是说,复制上传的文件////从其临时位置到所需位置////可以是$handle->Process('/home/www/my_ploads/');$handle->进程("../classified_images/");

        // we check if everything went OK
        if ($handle->processed) {
        $handle->image_convert = 'jpg';
        $newnamesmall =$adid."_small_".$tag_code_p;
        $handle->file_new_name_body   = $newnamesmall;
        $handle->image_resize          = true;          
        $handle->image_ratio_fill      = true;
        $handle->image_y               = 94;
        $handle->image_x               = 125;
        $handle->image_background_color = '#FFFFFF';
        // now, we start the upload 'process'. That is, to copy the uploaded file
        // from its temporary location to the wanted location
        // It could be something like $handle->Process('/home/www/my_uploads/');
        $handle->Process("../classified_images/");
        $handle->clean();
                //inserten in database
    $sql_foto_insert = "insert into  photos 
                ( adid,  photosmall,  photo)
                values
                ('$adid', '$newnamesmall.jpg','$newname.jpg')";
    $foto_result = mysql_query($sql_foto_insert);  
            // everything was fine !
            //$msg .= $oriname.' '.LANG_FOTOS_SAVED.'<br />';
            $allok = 1;
        } else {
            // one error occured
            $msg .= $handle->error . '<br />';
        }
    } 

这可能是由配置问题引起的。由于这种情况发生在大于特定大小的文件中,我觉得这可能与php.ini设置有关。

在php.ini设置中检查upload_max_filesizepost_max_size。这些可以设置为4MB。您可以增加这些值以使其工作。

如果您所在的共享托管环境中无法编辑php.ini,则可以将它们添加到.htaccess文件中,如下所示:

php_value upload_max_filesize 7M
php_value post_max_size 7M

此外,您应该从函数中删除@,看看错误是什么。在开发/调试时,通过添加@来抑制错误是个坏主意。

此外,如果您在本地机器或自己的开发服务器上,请打开apache error_log并检查最后几行以查看错误。如果您在第三方服务器上,大多数控制面板都提供了查看错误日志的界面。