move_uploaded_file不起作用,没有错误
|
我正在运行一个脚本,该脚本用
move_uploaded_file()
移动上传的文件。我已经做过数千次了,但是由于某种原因,它不起作用。我已确认以下内容:
<form>
使用method=\"post\"
并更正enctype
表格中引用的正确文件
目录具有权限777
所有memory_limit
,max_execution_time
等都设置为超高设置以避免超时
基本上,下面的脚本仅返回Your image is too big.
。我还启用了显示所有错误的提示,但仍然没有收到错误。有任何想法吗?
$time = time();
$target_path = \"/absolute/path/to/temp/directory/temp/\";
$target_path = $target_path.$time.\'.jpg\';
if(move_uploaded_file($_FILES[\'image\'][\'tmp_name\'], $target_path)) {
} else{
$error .= \'<li>Your image is too big.</li>\';
}
将1and1托管与php.ini hack结合使用:P
更新1
我想补充一点,就是脚本响应在60秒后发生。
更新2
我们可能对此有所了解。仅print_r($_FILES)
,这是数组的结果:
Array (
[image] => Array (
[name] => P2120267.JPG
[type] =>
[tmp_name] =>
[error] => 1
[size] => 0
)
)
因此,我认为该文件未正确上传到服务器或其他东西?我已经检查过,邮寄表格是is11ѭ。因此,据我所知,文件没有上传到服务器的临时区域吗?
更新3
注意上面数组中的ѭ12。显然这是因为文件大小大于upload_max_filesize
。但是,当我将其设置为128M
时,60秒后我会看到白色的死亡画面。我上传的文件为2.5MB
这是我的php.ini文件:
register_globals=off
memory_limit = 128M
max_execution_time=3600
post_max_size = 128M
upload_max_filesize= 128M
更新4
通过上面的详细信息,看来我正在获得WSOD,但是图像已被重新分配。那么,如何停止WSOD?我在任何地方都找不到任何错误。
更新5-找到了!
没给你们所有代码给我可耻。看起来与此行有关:
resizeImage($feedBurnerStatsSource, PHOTOMSGDIR.\'temp/\'.$time.\'-tmp.jpg\',$width,$height);
在下面的代码中:
function resizeImage($source, $destination = NULL,$wdt, $height = NULL){
if(empty($height)){
// Height is nit set so we are keeping the same aspect ratio.
list($width, $height) = getimagesize($source);
if($width > $height){
$w = $wdt;
$h = ($height / $width) * $w;
$w = $w;
}else{
$w = $wdt;
$h = $w;
$w = ($width / $height) * $w;
}
}else{
// Both width and Height are set.
// this will reshape to the new sizes.
$w = $wdt;
$h = $height;
}
$source_image = @file_get_contents($source) or die(\'Could not open\'.$source);
$source_image = @imagecreatefromstring($source_image) or die($source.\' is not a valid image\');
$sw = imagesx($source_image);
$sh = imagesy($source_image);
$ar = $sw/$sh;
$tar = $w/$h;
if($ar >= $tar){
$x1 = round(($sw - ($sw * ($tar/$ar)))/2);
$x2 = round($sw * ($tar/$ar));
$y1 = 0;
$y2 = $sh;
}else{
$x1 = 0;
$y1 = 0;
$x2 = $sw;
$y2 = round($sw/$tar);
}
$slate = @imagecreatetruecolor($w, $h) or die(\'Invalid thumbnail dimmensions\');
imagecopyresampled($slate, $source_image, 0, 0, $x1, $y1, $w, $h, $x2, $y2);
// If $destination is not set this will output the raw image to the browser and not save the file
if(!$destination) header(\'Content-type: image/jpeg\');
@imagejpeg($slate, $destination, 75) or die(\'Directory permission problem\');
ImageDestroy($slate);
ImageDestroy($source_image);
if(!$destination) exit;
return true;
}
因此,WSOD意味着它没有消息就死了。有任何想法吗?
没有找到相关结果
已邀请:
5 个回复
窃誓额
是否设置为较高水平?因为根据php.net: 如果发布数据的大小大于post_max_size,则$ _POST和$ _FILES超全局变量为空。可以通过各种方式来跟踪,例如通过将“ 19”变量传递给处理数据的脚本(即“ 20”),然后检查是否设置了“ 21”。 需要考虑的事情。 有关更多信息,请参见此链接并向下滚动到
部分 更新 以我的经验,如果您获得WSOD,通常会关闭
和
或达到
。我通常在顶部的脚本中将ѭ5设置为1024M以验证这不是问题,然后打开
和
...因此请将其放在文件上传之前:
通常可以摆脱WSOD并给您带来错误。 更新 您是否尝试过取消所有功能前面的“ 30”错误抑制功能,以查看它们正在产生特定的错误?另外,您执行和输入超时是什么?并且您可以验证正在发送哪些标头吗? (确保是
)
祁澈盘哼颗
...将此添加到处理上传的文件的开头。
辰炔诚薯
吞睫素
炬卤遁蝎变