Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: Multi-upload

  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts

    Multi-upload

    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 Code:
    <?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_namestrrpos($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_id0777);
                    
    mkdir($thumbDir.'/'.$album_id0777);
                }
                
                
    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

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,311
    Thanks
    58
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Quote Originally Posted by Chris-2k View Post
    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.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,311
    Thanks
    58
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    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?
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #5
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts
    yea a year doesn't seem that long ago!

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

  • #6
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts
    Ok,

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

    Here's the uploadify.php script:
    PHP Code:
    <?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

  • #7
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,915
    Thanks
    15
    Thanked 227 Times in 227 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •