Gdy wgrywam kilka zdjęć na raz i chcę zmienić ich rozdzielczość do dużej np. 1280x960 to wyskakuje mi błąd
Kod
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/upload/class.upload_0.26/class.upload.php on line 4047
Tutaj jest kod skryptu który wykombinowałem:
<?
include('./setting.php');
include('./class.upload_0.26/class.upload.php');
try
{
$pdo = new PDO('mysql:host=localhost;dbname=images', 'images', '******');
$pdo -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
echo 'Połączenie nie mogło zostać utworzone: ' . $e->getMessage(); }
$stm = $pdo -> query("SELECT `img_max_upload` FROM `config` LIMIT 1");
foreach ($stm as $rzad) {
for($i = 1; $i < $rzad['0']+2; $i++){
if($_FILES['image'.$i]['error']==0) {
$foo = new Upload($_FILES['image'.$i]);
if ($foo->uploaded) {
// save uploaded image with a new name
$foo->file_new_name_body = 'img';
if($_POST['resize'.$i]!='org') {
$foo->image_resize = true;
$foo->image_y = $_POST['resize'.$i];
$foo->image_ratio_x = true;
}
$foo->Process('./img');
if ($foo->processed) {
$img_name = $foo->file_dst_name;
} else {
echo 'error : ' . $foo->error; }
// save uploaded image with a new name,
// resized to thumb wide
$foo->file_new_name_body = 'img_thumb';
$foo->image_resize = true;
$st = $pdo -> query("SELECT `thumb_size` FROM `config` LIMIT 1");
foreach($st as $row) {
$foo->image_y = $row['thumb_size'];
}
$foo->image_ratio_x = true;
$foo->Process('./img');
if ($foo->processed) {
$thmb_name = $foo->file_dst_name;
$foo->Clean();
$stmt = $pdo -> prepare("INSERT INTO images (id, name_img, name_thmb, date) VALUES (NULL, :name_img, :name_thmb, :date)");
$date = date(Y
.'-'.m
.'-'.d
.' '.H
.':'); $stmt -> bindValue(':name_img', $img_name, PDO::PARAM_STR);
$stmt -> bindValue(':name_thmb', $thmb_name, PDO::PARAM_STR);
$stmt -> bindValue(':date', $date, PDO::PARAM_STR);
$ilosc = $stmt -> execute();
if($ilosc > 0) {
// echo 'Zauktualizowano: '.$ilosc.' rekordow';
echo '<form name="x"><div id="result"><img src="img/'.$thmb_name.'"> <div id="link" style="text-align:right;">Link do obrazka:
<input type="text" name="y" value="'.HTTP.'img/'.$img_name.'">
<a href="#" onclick="copy()">kopiuj</a></div>
<div id="form1" style="text-align:right;">Pełny rozmiar na forum:
<input readonly name="yz" type="text" size="30" value="[img='.HTTP
.'img/'.$img_name.']"> <a href="#" onclick="copy2()">kopiuj</a></div>
<div id="form1" style="text-align:right;">Pełny rozmiar na www:
<input readonly name="link" type="text" size="30" value="<a href="'.HTTP.'my.php?img='.$img_name.'"><img src="'.HTTP.'img/'.$img_name.'" border="0" alt="xxx"/></a>">
<input name="copy" type="button" value="Skopiuj"></div>
<div id="form1" style="text-align:right;">Mianiaturka na forum:
<input readonly name="link" type="text" size="30" value="[img='.HTTP
.'img/'.$thmb_name.']"> <input name="copy" type="button" value="Skopiuj"></div>
<div id="form1" style="text-align:right;">Miniaturka na www:
<input readonly name="link" type="text" size="30" value="<a href="'.HTTP.'my.php?img='.$img_name.'"><img src="'.HTTP.'img/'.$thmb_name.'" border="0" alt="xxx"/></a>">
<input name="copy" type="button" value="Skopiuj"></div>
</div>
</form>';
} else {
echo 'Wystapil blad podczas dodawania rekordow!'; }
} else {
echo 'error : ' . $foo->error; }
}
}
}
}
?>
Tu jest strona z przykładami tej klasy:
http://www.verot.net/php_class_upload.htmJak się pozbyć tego błędu?
Ten post edytował marcinpruciak 27.12.2008, 11:27:22