Witam!
Mam formularz w którym wrzucam sobie pliki...
<?php
echo '<form action="job.php?id=realise_add_s" method="post"> Temat: <input name="Text1" type="text" /><br />Opis:';
$sBasePath = $_SERVER['PHP_SELF'] ;
$sBasePath = substr( $sBasePath, 0
, strpos( $sBasePath, "_samples" ) ) ;
$oFCKeditor = new FCKeditor('home') ;
$oFCKeditor->BasePath = $sBasePath ;
$oFCKeditor->Value = '' ;
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '550' ;
$oFCKeditor->Create() ;
<br />
Zdjęcia: <input name="File1" type="file" /><br />
<input name="File2" type="file" /><br />
<input name="File3" type="file" /><br />
<input name="File4" type="file" /><br />
<input name="File5" type="file" /><br />
<input name="File6" type="file" /><br />
<input name="File7" type="file" /><br />
<input name="File8" type="file" /><br />
<br />
<input name="Submit1" type="submit" value="Zapisz" /></form>
';
?>
No i cóż... wszystkie dane mi przechodzą dalej oprócz obrazków
Skrypt wykonawczy:
<?php
$licz = 1;
while ($licz < 9) {
$file = 'File'.$licz;
if(!empty($_FILES[$file])) {
$width = 500;
$height = 500;
$images_res = $_FILES[$file]['tmp_name'];
$path_res = 'images/';
$name = $_FILES[$file]['tmp_name'];
require('img_res.php');
$width = 150;
$height = 150;
$images_res = $_FILES[$file]['tmp_name'];
$path_res = 'images/mini/';
$name = $_FILES[$file]['tmp_name'];
require('img_res.php');
}
$licz = $licz + 1;
}
echo '<a href="java script: history.go(-1)">Wróć</a>'; $query = "INSERT INTO `realis` (`id` ,`name` ,`add` ,`desc` ,`img1` ,`img2` ,`img3` ,`img4` ,`img5` ,`img6` ,`img7` ,`img8`) VALUES (
NULL , '".$_POST['Text1']."', NOW( ) , '".$_POST['home']."', '".$_FILES['File1']['name']."', '".$_FILES['File2']['name']."', '".$_FILES['File3']['name']."', '".$_FILES['File5']['name']."', '".$_FILES['File5']['name']."', '".$_FILES['File6']['name']."', '".$_FILES['File7']['name']."', '".$_FILES['File8']['name']."'
);";
echo 'Zmiany zostały zapisane!<br>'; ?>
plik img_res.php wygląda tak:
<?php
// Zmienne które muszą być zadeklarowane:
//$width - max długość
//$height - max wysokość
//$images_res - plik
//$path_res - ścieżka
$filename = $images_res;
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output
imagejpeg($image_p, $path_res . $conf, 75);
?>
Sposób działania jest prosty: podwójny zapis w dwóch różnych rozmiarach pod warunkiem że pole zostało wypełnione (jeśli nie zostało wypełnione ma być pomienięte)
Proszę o pomoc,
Pozdrawiam!