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 5 of 5
  1. #1
    Iys
    Iys is offline
    New to the CF scene
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Upload multiple images

    I have a image hosting script that is able to upload only one photo at a time.

    I've been trying to modify the script to enable users to upload a second image file at the same time without any success.

    Here is the URL to the demo of the script - http://tiny.cc/wjmx5w

    Also below is the PHP source code of the submit.php file.

    I'd appreciate any help on how I would go on about doing this.

    PHP Code:
    include("include/config.php");
    include(
    "include/functions/import.php");

    if(
    $_REQUEST['subimage']!="")
    {
        
    $accept_tos cleanit($_REQUEST['accept_tos']);
        
    $captcha cleanit($_REQUEST['captcha']);
        
    $uploadedimage $_FILES['postimage']['tmp_name'];
        if(
    $accept_tos != "1")
        {
            
    $error $lang['15'];
        }
        elseif(
    $captcha != $_SESSION['imagecode'])
        {
            
    $error $lang['14'];
        }
        elseif(
    $uploadedimage != "")
        {
            
    $query="INSERT INTO posts SET active='0', time_added='".time()."', date_added='".date("Y-m-d")."', ip='".$_SERVER['REMOTE_ADDR']."'";
            
    $result=$conn->execute($query);
            
    $id mysql_insert_id();

            
    $theimageinfo getimagesize($uploadedimage);
            
    $thepp $id;
        
            if(
    $theimageinfo[2] == 1)
            {
                
    $thepp .= "-o.gif";
                
    $thepp2 ".gif";
                
    $processgif "1";
            }
            elseif(
    $theimageinfo[2] == 2)
            {
                
    $thepp .= "-o.jpg";
                
    $thepp2 ".jpg";
            }
            elseif(
    $theimageinfo[2] == 3)
            {
                
    $thepp .= "-o.png";
                
    $thepp2 ".png";
            }
            else
            {
                
    $error $lang['16'];
            }
            
            if(
    $error == "")
            {
                
    $myvideoimgnew=$config['pdir']."/".$thepp;
                if(
    file_exists($myvideoimgnew))
                {
                    
    unlink($myvideoimgnew);
                }
                
    $myconvertimg $_FILES['postimage']['tmp_name'];
                
    move_uploaded_file($myconvertimg$myvideoimgnew);
                
                
                
                
                
                
                
                
                
    $tothumbdir $config['pdir']."/".$id.$thepp2;
                if(
    file_exists($tothumbdir))
                {
                    
    unlink($tothumbdir);
                }
                if(
    $processgif == "1")
                {
                    
    do_resize_image2($myvideoimgnew"800""5000"true$tothumbdir$config['pdir']."/z1-".$thepp2);
                    if(
    file_exists($config['pdir']."/z1-".$thepp2))
                    {
                        
    unlink($config['pdir']."/z1-".$thepp2);
                    }
                }
                else
                {
                    
    do_resize_image($myvideoimgnew"800""800"true$config['pdir']."/".$id.$thepp2"1");
                }
                
    $tothumbdirb $config['pdir']."/".$id."-t".$thepp2;
                if(
    file_exists($tothumbdirb))
                {
                    
    unlink($tothumbdirb);
                }
                if(
    $processgif == "1")
                {
                    
    do_resize_image2($myvideoimgnew"175""175"true$tothumbdirb$config['pdir']."/z1-".$thepp2);
                    if(
    file_exists($config['pdir']."/z1-".$thepp2))
                    {
                        
    unlink($config['pdir']."/z1-".$thepp2);
                    }
                }
                else
                {
                    
    do_resize_image($myvideoimgnew"175""175"false$config['pdir']."/".$id."-t".$thepp2"0");
                }
                
    $tothumbdirc $config['pdir']."/".$id."-t2".$thepp2;
                if(
    file_exists($tothumbdirc))
                {
                    
    unlink($tothumbdirc);
                }
                if(
    $processgif == "1")
                {
                    
    do_resize_image2($myvideoimgnew"100""100"true$tothumbdirc$config['pdir']."/z1-".$thepp2);
                    if(
    file_exists($config['pdir']."/z1-".$thepp2))
                    {
                        
    unlink($config['pdir']."/z1-".$thepp2);
                    }
                }
                else
                {
                    
    do_resize_image($myvideoimgnew"100""100"false$config['pdir']."/".$id."-t2".$thepp2"0");
                }
                
                
    //do_resize_image($myvideoimgnew, "800", "800", true, $config['pdir']."/".$id.$thepp2, "1");
                //do_resize_image($myvideoimgnew, "175", "175", false, $config['pdir']."/".$id."-t".$thepp2, "0");
                //do_resize_image($myvideoimgnew, "100", "100", false, $config['pdir']."/".$id."-t2".$thepp2, "0");
                
                
    if($config['wm'] == "1")
                {
                    if(
    $thepp2 != ".gif")
                    {
                        
    $watermark $config['imagedir']."/".$config['watermark'];
                        
                        if(
    $thepp2 == ".png")
                        {
                            
    $img=imagecreatefrompng($config['pdir']."/".$id.$thepp2);
                        }
                        else
                        {
                            
    $img=imagecreatefromjpeg($config['pdir']."/".$id.$thepp2);
                        }
                        
                        
                        
                        
    $img_width=imagesx($img);
                        
    $img_height=imagesy($img);
                        
    $watermark=imagecreatefrompng($watermark);  
                        
    $watermark_width=imagesx($watermark);  
                        
    $watermark_height=imagesy($watermark);  
                        
    $image=imagecreatetruecolor($watermark_width$watermark_height);  
                        
    imagealphablending($imagefalse);
                        
    $dest_x=$img_width-$watermark_width-5;
                        
    $dest_y=$img_height-$watermark_height-5;
                        
    imagecopy($img$watermark$dest_x$dest_y00$watermark_width$watermark_height);
                        
    imagesavealpha($imgtrue);
                        
    imagejpeg($img$config['pdir']."/".$id.$thepp290);     
                    }
                }
                
                if(
    file_exists($config['pdir']."/".$thepp))
                {
                    if(
    $config['approve_images'] == "0")
                    {
                        
    $active ", active='1'";
                    }
                    
                    
    $query "UPDATE posts SET ext='$thepp2' $active WHERE PID='".mysql_real_escape_string($id)."'";
                    
    $conn->execute($query);
                    
    $msg $lang['18'];
                }
                else
                {
                    
    $error $lang['17'];
                }
            }
        }
    }

    $pagetitle $lang['0'];
    STemplate::assign('pagetitle',$pagetitle);

    //TEMPLATES BEGIN
    STemplate::assign('error',$error);
    STemplate::assign('msg',$msg);
    STemplate::display('header.tpl');
    STemplate::display('submit.tpl');
    STemplate::display('footer.tpl');
    //TEMPLATES END
    ?> 

  • #2
    Iys
    Iys is offline
    New to the CF scene
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm not able to delete this thread but I've already figured out on how to do this with a simple for loop.

  • #3
    Regular Coder
    Join Date
    Sep 2002
    Posts
    459
    Thanks
    0
    Thanked 20 Times in 20 Posts
    You bought that or built it?
    NO Limits!! DHCreationStation.com
    ------------------------------------------------------------
    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com
    Global Complaint Dept.

  • #4
    Iys
    Iys is offline
    New to the CF scene
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, it was purchased.
    Is it against the rules posting purchased code? If so, I apoligize and please delete this threat.

  • #5
    Regular Coder
    Join Date
    Sep 2002
    Posts
    459
    Thanks
    0
    Thanked 20 Times in 20 Posts
    I only asked because I'm writing a tutorial series on building an image hosting service and that code looks like a nightmare to modify.
    NO Limits!! DHCreationStation.com
    ------------------------------------------------------------
    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com
    Global Complaint Dept.


  •  

    Posting Permissions

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