Add to Google

Image Upload And File Size

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Image Upload And File Size

kvarnerexpress
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.

 

 

 


Reply

arboc7
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!!

Reply

sonorama
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

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. free web host 500mb upload pdf - 431.01 hr back. (1)
  2. imagecopyresampled error mediawiki - 444.52 hr back. (1)
  3. mediawiki fileupload xampp error - 576.51 hr back. (1)
  4. php imagecreate filesize - 1220.82 hr back. (1)
Similar Topics

Keywords : image upload file

  1. Linux/ Apache /mod_rewrite Issue - Error when accessing a file (4)
  2. Php Ftp Upload Form - Adding User Directory to PHP Upload Form - Help (1)
    Alright I am trying to have a PHP FTP Upload Form that allows the user to create the directory
    folder for where they want to upload there files to. example: Main Directory: vainsoft.com There
    directory: vainsoft.com/modeling or vainsoft.com/photography But I dont want them to be able to
    upload things into the main directory, only sub-directories, is that possible with this coding that
    I have: //uses $_FILES global array //see manual for older PHP version info //This
    function will be used to get the extension from the filename function get_extension($fi...
  3. Watermark Your Image With Simple Php Script - found it on the net (35)
    This script was found on the net http://tips-scripts.com/?tip=watermark#tip B&T's Tips &
    Scripts site. Just in case the site may not show, I will include the code here: List of things
    needed: 1. your image in any format 2. watermark image--in gif format with transparent background 3.
    script below with name (i.e. watermark.php) CODE <?php // this script creates a watermarked
    image from an image file - can be a .jpg .gif or .png file // where watermark.gif is a mostly
    transparent gif image with the watermark - goes in the same directory as this script // ...
  4. Php Configuration File - "config.php" (16)
    I did create this topic mainly because I want to know everything about that configuration file. I
    will post other replies if I want to know more depending on your experience. Is this code correct
    for that file: CODE <? $host="localhost"; $dbname="XXX";
    $dbuser="XXX"; $dbpass="XXX";
    $connection=mysql_connect($host, $dbuser, $dbpass) or
    die(mysql_error()); mysql_select_db($dbname) or
    die(mysql_error()); ?> Add your suggestions or i...
  5. Image Upload - ?!? (11)
    I need the image upload script which automatically resized the image by specified size and store it
    in the specified folder....
  6. Upload Pics With Php? - (6)
    Can anyone help me out again? Thanks. I need a code that has a basic form that allows you to
    browse for an image file and when the submit button is clicked, that image gets uploaded to a folder
    in my site (e.g. images/*.jpg)...
  7. Getting List Of Directories And Files Using Php - PHP Function for Directory and File List (6)
    is there a php function that lists the content of some folder.... example: /New folder new.txt
    left.gif download.zip dc.exe ....so is there..? /rolleyes.gif' border='0'
    style='vertical-align:middle' alt='rolleyes.gif' /> ...
  8. Include File.php?id=something - using the include() function (13)
    Well, I am making a full CMS system for my site, and want to make the index.php file to include the
    view.php?id=1 file. I tried with this code, but it didn't work: CODE <?php include
    'view.php?id=1' ?> This is the error I get: CODE Warning:
    main(view.php?id=1) [function.main]: failed to open stream: Invalid argument
    in C:\server\xampp\htdocs\test\index.php on line 1 Warning:
    main() [function.include]: Failed opening 'view.php?id=1' for inclusion
    (i...
  9. Script: Php Jukebox - A one file script! (4)
    This scripts is so simple, you dont need to edit ANY of it! All you have to do is make a folder
    called 'songs' and put some audio files in it. Here is the whole page, I named it index.php
    and put it in a folder called 'music': CODE <!DOCTYPE HTML PUBLIC
    "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd"> <html> <head>
    <title>PHP jukebox</title> </head> <body> <!-- ©2005 Craig
    lloyd. All rights reserved. Visit cragllo.com for more sc...
  10. Need Some Help In File Browser - listing all sub folders and files in them. (8)
    Hey I want to create a very simple file browser, so that, it reads all the sub-folders which are
    places in a directory, and the files inside the sub-folders (It reads only files inside sub-folders
    and list them in simply. ) Also, it creates a directory (any name) inside each sub folder. My
    Following code reads on the files inside the main directory, it does not read the files inside the
    sub-folders.. I appreciate any help. CODE <? $path = "./"; $dir_handle =
    @opendir($path) or die("Unable to open $path"); whil...
  11. Updating Php File Through A Web Form - (5)
    Hello, i'm not sure if this can be done with php or not but what i need is a way to make an php
    file that have an html form on it and it will take the info you put in to that form and write it to
    an existing php file, for example: if i have the file news.php and the file news_update.php. if you
    went to news_update.php you would get an form with a text area for you to write a new addition for
    the news.php file and when you hit submit it will add what you typed in the form to the file
    news.php. If this is going to be a big code or a hard one to make but some one think...
  12. Dynamic Image / Signature Generator - a simple code to change text on an image (12)
    In search of dynamically changing quote, saying or all other types of text on an image I came across
    a code that I have modified to fit my initial usage. This procedure requires two files and short
    knowledge of PHP. If you are familiar with Trap17's sig rotation code you will understand this
    procedure very fast. Code 1: dynamic_sig.php (you can rename this to index.php and you'll see
    at the end why) Code 2: a simple text file named anything (I will call it name.txt ) Code 1
    CODE <?php header("Content-type: image/png"); �...
  13. File Checker-how To Check File Whith Html Through Html? - (2)
    edit:sorry for the mistake it is php not html and its with not whith my code checking script= CODE
    <?php $file = '$CHECK'; if (file_exists($file)) {
        echo "The file $filename exists"; } else {     echo "The file $filename
    does not exist"; } ?> my question is how to check the file whith html example:on a page
    a text box is provided and a button the user writes a file name (or website) the user clicks on the
    submit button then it checks and show it (with the code above) i got the code C...
  14. Php And Flash Image Gallery - Need some help in creating or editing an xml file while viewing some o (5)
    Hello there and thanks for the helping hand you are offering. PHP newbie here! /ph34r.gif"
    style="vertical-align:middle" emoid=":ph34r:" border="0" alt="ph34r.gif" /> So here is my problem:
    On my website I have a flash image gallery.The way the gallery works is by uploading pictures in a
    folder and editing? an xml file.(pics.xml) where it adds the following code when you upload a
    picture: CODE <pictures>     <image location="nameofpicture1.jpg"
    desc="" />     <image location="nameofpicture2.jpg" desc="" /&#...
  15. Batch Upload Script - In need of batch upload script (1)
    I'm in the process of making a photo gallery script. I need ideas on how to make a batch upload
    script. I want the user to be able to upload files to a folder via FTP and then go to the admin
    section of the gallery and add the previously uploaded photos to the MySQL database. I guess what I
    need it to do is find all the files in a specific folder and see if they are already in the
    database, if they aren't in the database - add them. Any help would be appreciated. I figured
    trap17 would be a good place to get help with this /wink.gif" style="vertical-align:middle...
  16. Get A Image Indentifier With Gd Library - GD library question (7)
    Hey fellow coders, I'm having a problem. If you output a im indentifier in php with gd libary.
    With this method for example: CODE <?
    header("(anti-spam-(anti-spam-(anti-spam-content-type:)))
    image/png"); $imgWidth = 50; $imgHeight = 50;
    $image=imagecreate($imgWidth, $imgHeight); $colorBlack =
    imagecolorallocate($image, 0, 0, 0);  // first color you define with colorallocate is
    also the color of the background of your image imagepng ($image); image...
  17. No File Extension - (3)
    On MediaWiki, the URL of the content is http://YOURWIKI.com/index.php/Blah Is it possible to
    create a page or two that doesn't have a file extension? If so, how is it done?...
  18. File Upload - File upload (1)
    I need to add a facility on my customer's website so his clients can send him jobs, typically
    5mb - 50mb. I've looked around the web and researched this, and tried a few tests (failed), but
    my brain's beginning to hurt. Could someone please tell me the best way to go about this,
    please. The site is done in Flash, but I'm sure a link to an html page would be ok if necessary....
  19. Trap17 Board Status Dynamic Image - (13)
    I was really board a few days ago and decided to make a trap17 board status image for my sig
    /tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> That is the
    current beta. I'm still working on it so that it might display the most recent post or
    somthing, i'm not sure. After I finish it ill give out the source code but if you want one
    right now you can pm me and ill set one up to get the info on your account ^.^ So I was wondering
    how you members liked it? You'll probably think that its a waist of time, but alas as I sai...
  20. <?php ?> Unique Visitors Script - Flat file unique visitors script (no sessions) (2)
    This is really simple script. Well at least this part is, but it could be extendable. Only problem
    is that it's not really for massive websites with hundread of visitors a day, but rather for
    small ones. But it is a good script to figure out how to make a visitor counter script. Anyway
    here's the snippet. CODE <?php function getVisits($variable) {
        $visits = array();     if ($handle =
    opendir('stats/')) {     while (false !== ($file =
    readdir($handle))) {  ...
  21. [php]simple Flat File Text Manipulator - Example on how to use forms to write to files in PHP (3)
    I made a simple flat file text editor, that can show you probably how simple it is to use forms with
    php and write that data to file. This example has 2 files, submit.php, and postit.html. Submit.php
    is used to write title, and some text, and add html tags, and paragraph tags where new paragraphs
    are. Here's the file with comments. I think that HTML really doesn't need some more
    explaining. CODE Title: <br /> <input type="text"
    name="title" size="53"> <br /> Text: <br />
    <textarea nam...
  22. Edit .txt File In Ftp Via Webpage - file on external ftp (2)
    Right Im new here and stuggling with a problem im having. I've currently got a Login Script to
    login to a external ftp and it displays the folders contents, however i need it so it echos a
    specific file (coursedata.cfg) into a formarea which you can then edit the file and when u click
    save it overwrites the file with the new one. Im really quiet getting annoyed with it xD as
    everything i do ends up trying to include the file from the webserver the script is hosted on and
    not the external ftp source. thanks Full Code Bellow Simple FTP Manager body { fon...
  23. Flipping An Animated Gif Image W/ Gd Library - Help (1)
    I need an animated gif image flipped using GD library in PHP. I wrote a script to flip still
    images, but it doesn't work on animated images. This is probably because I have the script
    moving 1 column of pixels at a time, and switching them around. How would I make multiple frames?
    Any help would be great! Thanks!...
  24. Php Help Needed Including File In A Page. - (2)
    i'm a noob in php programming, i can understand and modify php programs, but i dont know to
    write on my own. So please somebody who is well versed in php help me. My need is, I'm
    currently builiding a knowledge base website , i've my own design for the website, check here,
    http://laschatz.info/kzone/ Each page in the left hand site has a tree navigation of all the
    topics available. Since this information must be same in all the pages, presently I need to change
    all the pages after adding a new category. Could you please help me in such a way that I can ad...
  25. Help Php: How To Load String From Text File (solved) - Loading string from text file when you click on your link (9)
    I learned the way to load other files with the code posted on this forum. Now i wanted to try
    something for my side menu. I am calling this a string, --> $tekst , maybe it's
    called something else i'm not sure Now let's say i have a file called details.txt In that
    file i would like to have something like this $detailsaboutphp1 = ("details details details
    1"); $detailsaboutphp2 = ("details details details and even more details 2"); How to make a
    code that loads those $strings on click of a mouse. When we tried to load extern...
  26. I Need Help With File Edit In Php - with ftp (6)
    Currently i have CODE <?php if($_POST['user']=="" or
    $_POST['pass']=="" or $_POST['host']==""
    or $_POST['root']=="" or
    !isset($_POST['run'])){  print('<form method=post
    name=form>');  print('FTP username <input type=\'text\'
    name=user value=""><br>');  print('FTP password <input
    type=\'password\'...
  27. Help Needed With Directory/file Listing Code Infinite Loop - Made an infinite loop but why is this so? (5)
    Hi all ive got a small and simple (for the moment atleast /unsure.gif"
    style="vertical-align:middle" emoid=":unsure:" border="0" alt="unsure.gif" /> )file and directory
    listing script in php as follows CODE $dir = "."; $num = 0; $file =
    scandir($dir); while($file = scandir($dir)){     echo
    $file[$num];     echo "<BR>";     $num = $num + 1;     
    }; the concept is simple enough, the directory to start with is the current one, so scan this
    directory and wh...
  28. Display Random File In A Directory - how to display a random file from a set directory. (9)
    hi, could someone please help me with this? I have some files in a directory and i want to know how
    i can randomly display link/s to one or more of the files in my directory for download. But it must
    not at any time display index.php which is also in the directory with the downloads. Thanks in
    advance for any help given /unsure.gif" style="vertical-align:middle" emoid=":unsure:" border="0"
    alt="unsure.gif" />...
  29. Detect Image Resolution Without Gd - Also stop error if not found (1)
    Hi, I have come accross some starnge problem in PHP. I wanted to detect the image resolution in
    of a URL specified by the user. This is possible via getimagesize() function of PHP that is
    independent of GD library. But this function generates a E_WARNING Error if the image is not there.
    What shall i do to stop this warning ?? I dont want to show the Error in PHP style but my style of
    error reporting. Please help me....
  30. File Format Unknown! (wap) - someone PLEASE HELP! (6)
    hi people :-) listen please can someone help me find the error in this wapsite page, its driving me
    nuts! It works fine on some phones but not on others (giving a file format unknown error) and im
    having serious problems finding the error but i bet its something stupid/simple. CODE <?php
    include ("config.php"); include ("core.php");
    header("Content-type: text/vnd.wap.wml"); header("Cache-Control:
    nostore, nocache, mustrevalidate"); print "<?xml version=\"1.0\&#...



Looking for image, upload, file, size

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for image, upload, file, size

*MORE FROM TRAP17.COM*
Linux/
Apache
/mod_rewrite
Issue Error
when
accessing a
file
Php Ftp
Upload Form
Adding User
Directory to
PHP Upload
Form - Help
Watermark
Your Image
With Simple
Php Script
found it on
the net
Php
Configuratio
n File
"config.
php"
Image Upload
?!?
Upload Pics
With Php?
Getting List
Of
Directories
And Files
Using Php
PHP Function
for
Directory
and File
List
Include
File.php?id=
something
using the
include()
function
Script: Php
Jukebox A
one file
script!
Need Some
Help In File
Browser
listing all
sub folders
and files in
them.
Updating Php
File Through
A Web Form
Dynamic
Image /
Signature
Generator a
simple code
to change
text on an
image
File
Checker-how
To Check
File Whith
Html Through
Html?
Php And
Flash Image
Gallery Need
some help in
creating or
editing an
xml file
while
viewing some
o
Batch Upload
Script In
need of
batch upload
script
Get A Image
Indentifier
With Gd
Library GD
library
question
No File
Extension
File Upload
File upload
Trap17 Board
Status
Dynamic
Image
<?php
?> Unique
Visitors
Script Flat
file unique
visitors
script (no
sessions)
[php]simple
Flat File
Text
Manipulator
Example on
how to use
forms to
write to
files in PHP
Edit .txt
File In Ftp
Via Webpage
file on
external ftp
Flipping An
Animated Gif
Image W/ Gd
Library Help
Php Help
Needed
Including
File In A
Page.
Help Php:
How To Load
String From
Text File
(solved)
Loading
string from
text file
when you
click on
your link
I Need Help
With File
Edit In Php
with ftp
Help Needed
With
Directory/fi
le Listing
Code
Infinite
Loop Made an
infinite
loop but why
is this so?
Display
Random File
In A
Directory
how to
display a
random file
from a set
directory.
Detect Image
Resolution
Without Gd
Also stop
error if not
found
File Format
Unknown!
(wap)
someone
PLEASE
HELP!
advertisement



Image Upload And File Size



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE