Chris-2k
07-19-2012, 09:31 PM
hi
one more job for me to do is add a multi-upload feature to my script, i found uploadify... http://uploadify.com/ neat an clever plugin!
i've tried using my uploader.php, itdoesn't like, i get HTTP 404 error, so can anyone help me plz? here's my uploader.php:
<?php
/**************************************************************************************************** *************************************/
/***************************************** This script was writtn by Christopher Reynolds. Feb 2011 **************************************/
if(isset($_FILES['image_upload']) && !empty($_FILES['image_upload'])) {
$temp_name = $_FILES['image_upload']['tmp_name']; //temp file name and location
$orig_name = $_FILES['image_upload']['name']; //file name
$type = $_FILES['image_upload']['type']; // type of file
$size = $_FILES['image_upload']['size']; //size of the mage in bytes
$ext = substr($orig_name, strrpos($orig_name, '.')); //grab file extension
$ext = strtolower($ext); // get the extension of the file in a lower case format
if (in_array($type, $allowed) && ($size <= $maxfileSize) && ( $width < $maxWidth && $height < $maxHeight )) {
$new_name = gen_uniqueFilename().$ext; //we will give an unique name
if(loggedin()) {
$album_id = $_POST['album_id'];
$album_id = (int)$album_id; // for security
mysql_query("INSERT INTO images VALUES ('', '".$_SESSION['user_id']."', '".$album_id."', '".$new_name."', '".date('D, M Y')."', '".$ext."', '1')");
$image_id = mysql_insert_id();
if(!is_dir($uploadDir.'/'.$album_id) && !is_dir($thumbDir.'/'.$album_id)) {
mkdir($uploadDir.'/'.$album_id, 0777);
mkdir($thumbDir.'/'.$album_id, 0777);
}
move_uploaded_file($temp_name, $uploadDir.'/'.$album_id.'/'.$new_name);
$url = $siteURL .'/'. $uploadDir .'/'. $album_id .'/'. $new_name;
$thumb = $siteURL .'/'. $thumbDir .'/'. $album_id .'/thumb_'. $new_name;
if(isset($customPixels) && !empty($customPixels) && is_numeric($customPixels)) {
create_thumb($customPixels, $url, $new_name, $type, $thumbDir.'/'.$album_id.'/');
}
} else {
move_uploaded_file($temp_name, $uploadDir.'/'.$new_name);
$url = $siteURL .'/'. $uploadDir .'/' . $new_name;
$thumb = $siteURL .'/'. $thumbDir .'/thumb_'. $new_name;
if(isset($customPixels) && !empty($customPixels) && is_numeric($customPixels)) {
create_thumb($customPixels, $url, $new_name, $type, $thumbDir);
}
}
if (isset($email) && !empty($email)) {
send_an_email($email, $url, $thumb);
}
include $theme .'/uploaded.php';
} else {
trigger_error('<p align=\'center\' class=\'select_text\'>Your file failed too upload, maybe the file size is bigger than 3 MB or it\'s an invalid type or the dimensions are too large.</p>');
}
} // < attempting a local upload and all checks.
?>
Thanks
one more job for me to do is add a multi-upload feature to my script, i found uploadify... http://uploadify.com/ neat an clever plugin!
i've tried using my uploader.php, itdoesn't like, i get HTTP 404 error, so can anyone help me plz? here's my uploader.php:
<?php
/**************************************************************************************************** *************************************/
/***************************************** This script was writtn by Christopher Reynolds. Feb 2011 **************************************/
if(isset($_FILES['image_upload']) && !empty($_FILES['image_upload'])) {
$temp_name = $_FILES['image_upload']['tmp_name']; //temp file name and location
$orig_name = $_FILES['image_upload']['name']; //file name
$type = $_FILES['image_upload']['type']; // type of file
$size = $_FILES['image_upload']['size']; //size of the mage in bytes
$ext = substr($orig_name, strrpos($orig_name, '.')); //grab file extension
$ext = strtolower($ext); // get the extension of the file in a lower case format
if (in_array($type, $allowed) && ($size <= $maxfileSize) && ( $width < $maxWidth && $height < $maxHeight )) {
$new_name = gen_uniqueFilename().$ext; //we will give an unique name
if(loggedin()) {
$album_id = $_POST['album_id'];
$album_id = (int)$album_id; // for security
mysql_query("INSERT INTO images VALUES ('', '".$_SESSION['user_id']."', '".$album_id."', '".$new_name."', '".date('D, M Y')."', '".$ext."', '1')");
$image_id = mysql_insert_id();
if(!is_dir($uploadDir.'/'.$album_id) && !is_dir($thumbDir.'/'.$album_id)) {
mkdir($uploadDir.'/'.$album_id, 0777);
mkdir($thumbDir.'/'.$album_id, 0777);
}
move_uploaded_file($temp_name, $uploadDir.'/'.$album_id.'/'.$new_name);
$url = $siteURL .'/'. $uploadDir .'/'. $album_id .'/'. $new_name;
$thumb = $siteURL .'/'. $thumbDir .'/'. $album_id .'/thumb_'. $new_name;
if(isset($customPixels) && !empty($customPixels) && is_numeric($customPixels)) {
create_thumb($customPixels, $url, $new_name, $type, $thumbDir.'/'.$album_id.'/');
}
} else {
move_uploaded_file($temp_name, $uploadDir.'/'.$new_name);
$url = $siteURL .'/'. $uploadDir .'/' . $new_name;
$thumb = $siteURL .'/'. $thumbDir .'/thumb_'. $new_name;
if(isset($customPixels) && !empty($customPixels) && is_numeric($customPixels)) {
create_thumb($customPixels, $url, $new_name, $type, $thumbDir);
}
}
if (isset($email) && !empty($email)) {
send_an_email($email, $url, $thumb);
}
include $theme .'/uploaded.php';
} else {
trigger_error('<p align=\'center\' class=\'select_text\'>Your file failed too upload, maybe the file size is bigger than 3 MB or it\'s an invalid type or the dimensions are too large.</p>');
}
} // < attempting a local upload and all checks.
?>
Thanks