But this is not the only image that fails.
Most of the time the code works and uploads the fiel and renames it as set in the changename function.
But others it just throws the error i setup that says that 'uploaderror'
Am I doing this right or have I something else that is going on that may explain why this code can not do what I thought it should.
this is my PHP...
- Code: Select all
// upload images if any.
if (isset($_FILES['files']['type']) && count(explode("||", $filenames)) < 3) { // Check if there are under 3 images in the DB and that FILES isset.
$num = count($_FILES['files']['type']);
if ($num >= 1) { $uploadError = ""; $fileError = "";
//require('includes/class.image-resize.php'); $obj = new img_opt(); $obj->max_width(250);
//$obj->max_height(250); $obj->image_path($_FILES['files']['tmp_name'][0]); $obj->image_resize();
for($i = 0; $i < $num; $i++) {
if ($_FILES['files']['name'][$i] != "") {
//Now me must change the name
// now check if file EXT is valid. if not do not upload image which will mean that the file name is not stored.
if (0 == 0) {
$newFileName = changename($i,$_FILES['files']['name'][$i]);
//echo("<br><br>:" . $newFileName . ":<br><br>"); // exit;
$newFilenameL = '/home/****/public_html/****/itemImages/L'.$newFileName;
$newFilenameS = '/home/****/public_html/****/itemImages/S'.$newFileName;
echo("<br>uploaderror<br>:" . $uploadError . ":L". $newFileName . ":<br>");
if (move_uploaded_file($_FILES['files']['tmp_name'][$i], $newFilenameL)) {
$filenames .= ''.$newFileName . '||';
///
$resizeObj = new resize($newFilenameL); // *** 1) Initialise / load image
$resizeObj -> resizeImage(400, 400, 'auto'); // *** 2) Resize image (options: exact, portrait, landscape, auto, crop)
$resizeObj -> saveImage($newFilenameL, 100); // *** 3) Save image
///
///
$resizeObj = new resize($newFilenameL); // *** 1) Initialise / load image
$resizeObj -> resizeImage(100, 100, 'auto'); // *** 2) Resize image (options: exact, portrait, landscape, auto, crop)
$resizeObj -> saveImage($newFilenameS, 100); // *** 3) Save image, 100 being the % of quality.
///
} else {
$uploadError = "uploadError";
}
} else {
$fileError = "EXTerror";
}
}
}
}
} else {
// clear files as there are already 3 in the DB.
unset($_FILES['files']);
}
and the functions
- Code: Select all
function changename($var,$string) {
//echo("<br><br><br>:1:".$string."::<br><br><br>");
$string = explode(".",$string); $t=time();
//echo("<br><br><br>:2:".print_r($string)."::<br><br><br>");
$user=$_SESSION['user']['userid'];
$name=$t.$user.$var.".".strtolower($string[1]);
return $name;
}


