Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Image Upload And File Size
kvarnerexpress
post Nov 14 2005, 09:01 PM
Post #1


Super Member
*********

Group: Members
Posts: 407
Joined: 13-December 04
Member No.: 2,696



Hi,

I'm trying to upload rather large jpgs files (2560x1920 and ~ 2 megs in size) to my server via PHP. The problem I am having is that when I upload and attempt to resize by creating a new image, the new image is always black.

Code I'm using is:

PHP Code:
CODE
if( !empty($thefile_name) ) {
                           
               
           
                   
                   $query = "INSERT INTO coldwell_images (imagename) VALUES ('insertimage')";
                   $result = mysql_query($query) or die("Query failed");
                   
                   $query = "SELECT LAST_INSERT_ID() as maxID FROM coldwell_images";
                   $result = mysql_query($query) or die("Query failed");
                   $line = mysql_fetch_array($result, MYSQL_ASSOC);
                                       
                   $newID = $line['maxID'];
                   
                   
                   if ($thefile_type == "image/gif")
                       $thefile_name_new = $newID . ".gif";
                   else
                       $thefile_name_new = $newID . ".jpg";
                       
                   $aNewName = "/xxx/users/u60/nbcom/public_html/images/upload/" . $thefile_name_new;
                   copy($thefile,$aNewName);
                   
                   $image_size = getImageSize($aNewName);
                   
                   if ($thefile_type == "image/gif")
                       $new_image = imageCreateFromGIF($aNewName);
                   else
                       $new_image = imageCreateFromJPEG($aNewName);
                   
                   unlink($aNewName);
                   
                    // Create large image
                    if ($orientation == "horz") {
                        $tmp_image = imageCreateTrueColor(385, 240);
                        imagecopyresampled($tmp_image, $new_image, 0, 0, 0, 0, 385, 240, $image_size[0], $image_size[1]);
                    } else {
                         $tmp_image = imageCreateTrueColor(180, 240);
                        imagecopyresampled($tmp_image, $new_image, 0, 0, 0, 0, 180, 240, $image_size[0], $image_size[1]);
                    }
                   
                    imagejpeg($tmp_image, $aNewName, 100);
                    imageDestroy($tmp_image);
                   
                   
                    $query = "UPDATE coldwell_images SET
                              imagename = '$imagename'
                              ,imagefilename = '$thefile_name_new'
                              ,folder = '$folder'
                              ,orientation = '$orientation'
                              WHERE id = $newID";
                             
                    $result = mysql_query($query) or die("Query failed");
                   
                    $largeImage = $thefile_name_new;
                   
                   
                                             
                       imageDestroy($new_image);
                   
                   
                   
               
               
               
           }else{
                   $errorMsg = "No File.";
           }



I also have my memory limit set high ,ini_set("memory_limit","100M"), just in case it was something to do with the filesize. If I lower the filesize to ~ 1800x1300, then everything works fine.
Go to the top of the page
 
+Quote Post
arboc7
post Nov 15 2005, 01:37 AM
Post #2


Advanced Member
*******

Group: Members
Posts: 123
Joined: 5-September 05
Member No.: 11,522



That's weird...I don't see anything wrong with your code...

All I can think of is that the file might be too big, so the upload could be timing out, and, therefore, you get the black image. That might also explain why you can upload the smaller picture, because it wouldn't time out...

Good luck!!
Go to the top of the page
 
+Quote Post
sonorama
post Nov 15 2005, 05:08 AM
Post #3


Premium Member
********

Group: Members
Posts: 197
Joined: 3-April 05
From: Cuernavaca, Mexico
Member No.: 5,226



Right, I dont see anything wrong with your code either. But I am not sure either if it is because of the size. You should try changing the size and see if it works out.

Cheers!!! rolleyes.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Getting List Of Directories And Files Using Php(6)
  2. Upload Pics With Php?(6)
  3. Script: Php Jukebox(4)
  4. I Need Help With File Edit In Php(6)
  5. Include File.php?id=something(13)
  6. Dynamic Image / Signature Generator(12)
  7. Watermark Your Image With Simple Php Script(35)
  8. Display Random File In A Directory(9)
  9. Help Needed With Directory/file Listing Code Infinite Loop(5)
  10. Help Php: How To Load String From Text File (solved)(9)
  11. Php Help Needed Including File In A Page.(2)
  12. Flipping An Animated Gif Image W/ Gd Library(1)
  13. Edit .txt File In Ftp Via Webpage(2)
  14. [php]simple Flat File Text Manipulator(3)
  15. <?php ?> Unique Visitors Script(2)
  1. Trap17 Board Status Dynamic Image(13)
  2. Batch Upload Script(1)
  3. File Upload(1)
  4. No File Extension(3)
  5. Php And Flash Image Gallery(5)
  6. Get A Image Indentifier With Gd Library(7)
  7. File Checker-how To Check File Whith Html Through Html?(2)
  8. Php Ftp Upload Form(1)
  9. Updating Php File Through A Web Form(5)
  10. Need Some Help In File Browser(8)
  11. Image Upload(11)
  12. Php Configuration File(16)
  13. Linux/ Apache /mod_rewrite Issue(4)


 



- Lo-Fi Version Time is now: 6th October 2008 - 11:51 AM