我有這樣的腳本:庫文件上傳問題PHP的
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文件擴展名,並且safe_mode被關閉到使用CGI模式的php5,並且gd2處於活動狀態。可能是什麼問題呢?
可能重複[在PHP中上傳最大大小?](http://stackoverflow.com/questions/3263480/upload-max-size-in-php) – 2011-03-02 11:54:38
@Col。彈片你是什麼意思。我已經在php5.ini中聲明瞭代碼 – Victor 2011-03-02 12:24:12
中沒有最大尺寸語句,但在鏈接的答案中有幾個** PHP設置。你試過嗎? – 2011-03-02 12:26:03