...

View Full Version : Multi-upload



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

tangoforce
07-19-2012, 09:38 PM
i've tried using my uploader.php, itdoesn't like, i get HTTP 404 error

The 404 means that you've used an incorrect address somewhere not that your uploader.php has a fault.

Chris-2k
07-19-2012, 09:57 PM
Yea I no that, but i don't see how. hmm m8 I kno you're good PHPer, you did a job for mea year ago.... can i grab half an hour on TV with you?

tangoforce
07-19-2012, 10:26 PM
Maybe tomorrow but not tonight, I am very busy these days with other things.

The 404 is not a php related issue and to be honest, it's not really the sort of thing that requires TV to solve. File paths can be confusing at the best of times and thats why YOU need to get it straight in your head what is going on.

A year ago.... ? Has it really been so long? :eek:

Chris-2k
07-19-2012, 11:32 PM
yea a year doesn't seem that long ago!

can you not fit half an hour now, ill dnate if needed.

Chris-2k
07-22-2012, 10:08 PM
Ok,

I am at the end of my teather now, tryna implement cuploadify...

Here's the uploadify.php script:

<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/

// Define a destination
$targetFolder = '/uploads'; // Relative to the root

if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];

// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);

if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo '1';
} else {
echo 'Invalid file type.';
}
}
?>

NOTE: My uploader.php is in 1st post and i get 404 when uploading files? (my uploader.php works when uploadify's disabled.)

But that uploadify.php script works......

Any help............
Thanks

DrDOS
07-23-2012, 03:58 AM
Look in the snippets, I just put a multi upload script in there. It's all on one page and it works. I didn't have any plans to use it so I didn't fully develop it, but it makes a good starting point for anyone who needs one.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum