我有这个脚本:
if(($_POST['number2'] && !$_POST['button_add']) || ($_POST['number2'] && !$_POST['button_add_gal'])) { $num=$_POST['number2'];
for($p=0; $p<$num; $p++) {
if ($_POST['page']=='news') {
$dir = '../images/news/'; // Директорията в която ще се записват файловете
}
if ($_POST['page']=='gallery') {
$dir = '../images/gallery/'; // Директорията в която ще се записват файловете
}
$name[$p]='gal_'.$_FILES['file']['name'][$p];
move_uploaded_file($_FILES['file']['tmp_name'][$p], $dir.$name[$p]);
$filename[$p] = $name[$p];
if ($_POST['page']=='news') {
createThumb('../images'.DIRECTORY_SEPARATOR.'news'.DIRECTORY_SEPARATOR.$filename[$p]);
echo '<img src="../images/news/thumb_'.$filename[$p].'" width="50" height="50" border="0" style="margin-left:10px;">';
}
if ($_POST['page']=='gallery') {
createThumb('../images'.DIRECTORY_SEPARATOR.'gallery'.DIRECTORY_SEPARATOR.$filename[$p]);
echo '<img src="../images/gallery/thumb_'.$filename[$p].'" width="50" height="50" border="0" style="margin-left:10px;">';
if($_POST['page']=='gallery'){
resizeImage('../images'.DIRECTORY_SEPARATOR.'gallery'.DIRECTORY_SEPARATOR.$filename[$p]); }
if ($_POST['page']=='news'){
resizeImage('../images'.DIRECTORY_SEPARATOR.'news'.DIRECTORY_SEPARATOR.$filename[$p]);
}
}
} }
function createThumb($source, $thumb_width=150)
{
$fl = dirname($source);
$new_name = 'thumb_'.basename($source);
$img = imagecreatefromjpeg($source);
$width = imagesx($img);
$height = imagesy($img);
$new_width = $thumb_width;
$new_heght = floor($height * ($thumb_width / $width));
$tmp_img = imagecreatetruecolor( $new_width, $new_heght );
imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_heght, $width, $height);
imagejpeg($tmp_img, $fl.DIRECTORY_SEPARATOR.$new_name);
}
function resizeImage($source, $thumb_width=700)
{
$fl = dirname($source);
$new_name = basename($source);
$img = imagecreatefromjpeg($source);
$width = imagesx($img);
$height = imagesy($img);
$new_width = $thumb_width;
$new_heght = floor($height * ($thumb_width / $width));
$tmp_img = imagecreatetruecolor( $new_width, $new_heght );
imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_heght, $width, $height);
imagejpeg($tmp_img, $fl.DIRECTORY_SEPARATOR.$new_name);
}
它适用于小图片,但如果我使用更大的图片,它只适用于2个文件。如果我附加3个或更多文件,则上传它们,当页面刷新时,期望看到上传的图片,页面上没有任何内容。它返回默认状态。甚至没有显示错误消息。我将php5.ini upload_max_filesize
重新配置为100M但仍然没有。我使用php5文件扩展名,并且使用CGI模式将safe_mode关闭到php5并且gd2处于活动状态。可能是什么问题?
答案 0 :(得分:-1)
我想知道你的脚本是否超时?添加ini_set(“max_execution_time”,500);或者在脚本顶部的东西,看看是否有帮助