Salve , qual'è l'istruzione che posso fare rallentare un for che questo for fa un resize delle immagini e le inserisce nel db.
in questo codie:
codice:
$cartella = opendir("".$dir_admin_photo."".$row_dir.'/auto/');while ($file = readdir($cartella)) {
$file_array[] = $file;
}
foreach ($file_array as $file) {
if ( $file == ".." || $file == ".") {
continue;
}
$file_name = "".sha1($file).".jpg";
$resizer = new ImageResizer("".$dir_admin_photo."".$row_dir."/auto/".$file."","".$dir_admin_photo."".$row_dir."/big/".strtolower($file_name)."");
$resizer->resizeImage(800,600);
$resizer = new ImageResizer("".$dir_admin_photo."".$row_dir."/auto/".$file."","".$dir_admin_photo."".$row_dir."/thumb/".strtolower($file_name)."");
$resizer->resizeImage(150,150);
$content = "";
$active =1;
$data_reg = date("Y-m-d H:i:s");
$id_users = $_SESSION["id_users"];
$query = "INSERT INTO photo (id_categories,url,content,active,data_reg)VALUES(:id_categories,:url,:content,:active,:data_reg)";
$stmt = $db->prepare($query);
$stmt->bindParam(':id_categories', $id_categories, PDO::PARAM_INT);
$stmt->bindParam(':url', $file_name, PDO::PARAM_STR);
$stmt->bindParam(':content',$content, PDO::PARAM_STR);
$stmt->bindParam(':active', $active, PDO::PARAM_INT);
$stmt->bindParam(':data_reg', $data_reg, PDO::PARAM_STR);
$stmt->execute();
unlink("".$dir_admin_photo."".$row_dir."/auto/".$file."");
}
echo "Fatto";
}
perché se lo lancio e ho tantissime foto lo script si blocca con un time out.
come posso fare?
grazie mille e buona serata.