Jump to content

Image Upload Problems


codexx

Recommended Posts

Hey Everyone,

 

I have this following script that uploads then ftp's the file to another server. I'm having a problem where it won't let me upload files over 1.5 MB.

 

     

<?php
     if($_FILES['image']['type'] == 'image/pjpeg' || $_FILES['image']['type'] == 'image/gif'){
	   $size = 90; // the thumbnail width		   
           $maxfile = '200000'; //maximum file size to upload
           $mode = '0666';
           $userfile_name = $_FILES['image']['name'];
           $userfile_tmp = $_FILES['image']['tmp_name'];
           $userfile_size = $_FILES['image']['size'];
           $userfile_type = $_FILES['image']['type'];
           if (isset($_FILES['image']['name'])) 
           {
               $prod_img = "tmp/".$_SESSION['onlineuser']."-original".$_FILES['image']['name'];
               $prod_img_thumb = "tmp/".$_SESSION['onlineuser']."-".$_FILES['image']['name'];
		                move_uploaded_file($userfile_tmp, $prod_img);
               chmod ($prod_img, octdec($mode));
               $sizes = getimagesize($prod_img);
               $aspect_ratio = $sizes[1]/$sizes[0]; 
               if ($sizes[0] <= $size)
              {
                  $new_width = $sizes[0];
                  $new_height = $sizes[1];
               }else{
                   $new_height = $size;
                   $new_width = abs($new_height/$aspect_ratio);
               }
               $destimg=imagecreatetruecolor($new_width,$new_height) or die('Problem In Creating image');
               $srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image');
               ImageCopyResampled($destimg, $srcimg, 0, 0, 0, 0, $new_width, $new_height, $sizes[0], $sizes[1]) or die('Problem In resampling');
             ImageJPEG($destimg,$prod_img_thumb,50) or die('Problem In saving');

               imagedestroy($destimg);
           }
	   

	//Update User Account


	//FTP It to image servers
 $ftp_server = "mysite.com";      // FTP Server Address (exlucde ftp://)
    $ftp_user_name = "[email protected]";     // FTP Server Username
    $ftp_user_pass = "password";      // Password

$conn_id = ftp_connect($ftp_server);
    // Login to FTP Server
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
    
    // Verify Log In Status
    if ((!$conn_id) || (!$login_result)) {
        echo "Upload connection has failed! <br />";
          exit;
    } else {
       
    }
$time = time();
$local_file = "tmp/".$_SESSION['onlineuser']."-".$_FILES['image']['name'];

    $destination_file = "/thumb/".$_SESSION['onlineuser']."-".$time.".jpg";  // Path for File Upload (relative to your login dir)
    $upload = ftp_put($conn_id, $destination_file, $local_file, FTP_BINARY);  // Upload the File

$local_file = "tmp/".$_SESSION['onlineuser']."-original".$_FILES['image']['name'];

    $destination_file = "/".$_SESSION['onlineuser']."-large".$time.".jpg";  // Path for File Upload (relative to your login dir)
    $upload = ftp_put($conn_id, $destination_file, $local_file, FTP_BINARY);  // Upload the File
    
    // Verify Upload Status
   
    ftp_close($conn_id); // Close the FTP Connection
dbConnect();
$url = "http://mysite.com/".$_SESSION['onlineuser']."-large".$time.".jpg";
         $update = mysql_query ("UPDATE members SET prolargeimg_1 = '".$url."', proimg_1 = mysite.com/thumb/".$_SESSION['onlineuser']."-".$time.".jpg' WHERE username = '".$_SESSION['onlineuser']."'");


	 ?>
         
		  <h2> Complete </h2> <?
       }else{
   ?> This is an invalid file type, you must upload a jpeg photo! <?
  } ?> 

Link to comment
https://forums.phpfreaks.com/topic/63272-image-upload-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.