File Upload Problem with Thumbnails

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • callieandmark@yahoo.co.uk

    File Upload Problem with Thumbnails

    I have a very simple file upload script which creates a thumbnail of
    the file (jpg) upon uploading. This works fine with small images,
    however, if i try to upload a file over about 1mb the thumbnail
    dosen't show. Any ideas ?
    Thanks for any advice.

  • Mike Roetgers

    #2
    Re: File Upload Problem with Thumbnails

    callieandmark@y ahoo.co.uk schrieb:
    I have a very simple file upload script which creates a thumbnail of
    the file (jpg) upon uploading. This works fine with small images,
    however, if i try to upload a file over about 1mb the thumbnail
    dosen't show. Any ideas ?
    Thanks for any advice.
    >
    Maybe post_max_size is set to 1M in your php.ini?

    Comment

    • callieandmark@yahoo.co.uk

      #3
      Re: File Upload Problem with Thumbnails

      No, the post_max is set at 8M
      Thanks

      Comment

      • shimmyshack

        #4
        Re: File Upload Problem with Thumbnails

        On 26 Mar, 15:06, "callieandm...@ yahoo.co.uk"
        <callieandm...@ yahoo.co.ukwrot e:
        No, the post_max is set at 8M
        Thanks
        advice is to post your code for better answers.
        Do you use exif data to create the thumb, perhaps the larger jpgs
        don't have that info, etc.. just guesses at this point.

        Comment

        • delishus

          #5
          Re: File Upload Problem with Thumbnails

          On Mar 26, 5:53 am, "callieandm...@ yahoo.co.uk"
          <callieandm...@ yahoo.co.ukwrot e:
          I have a very simple file upload script which creates a thumbnail of
          the file (jpg) upon uploading. This works fine with small images,
          however, if i try to upload a file over about 1mb the thumbnail
          dosen't show. Any ideas ?
          Thanks for any advice.
          You also need to check the size of your upload_max_file size in the
          php.ini - if your post_max is 8M, then your upload_max is probably
          only 2M.

          Comment

          • callieandmark@yahoo.co.uk

            #6
            Re: File Upload Problem with Thumbnails

            The upload max is 20M.
            If i try to upload a large file (over 1mb) it uploads fine, its just
            that the thumbnail is not created.

            The code is :
            $tsize = "300"; //thumbnails size (pixel)
            $path = "uploads/"; //image path, where the images should be
            uploaded to
            $tpath = "thumbs/"; //your thumbnails path
            $name="$uploade d_file_name";
            $imgf = "$uploaded_file _name";
            $thbf = $tpath.$imgf;
            function createthumb($na me,$filename,$n ew_w,$new_h){
            $system=explode ('.',$name);
            if (preg_match('/jpg|jpeg|JPG/',$system[1])){
            $src_img=imagec reatefromjpeg($ name);
            }
            if (preg_match('/png|PNG/',$system[1])){
            $src_img=imagec reatefrompng($n ame);
            }
            if (preg_match('/gif|GIF/',$system[1])){
            $src_img=imagec reatefromgif($n ame);
            }

            $old_x=imageSX( $src_img);
            $old_y=imageSY( $src_img);
            if ($old_x $old_y) {
            $thumb_w=$new_w ;
            $thumb_h=$old_y *($new_h/$old_x);
            }
            if ($old_x < $old_y) {
            $thumb_w=$old_x *($new_w/$old_y);
            $thumb_h=$new_h ;
            }
            if ($old_x == $old_y) {
            $thumb_w=$new_w ;
            $thumb_h=$new_h ;
            }

            $dst_img=ImageC reateTrueColor( $thumb_w,$thumb _h);
            imagecopyresamp led($dst_img,$s rc_img,0,0,0,0, $thumb_w,$thumb _h,$old_x,
            $old_y);


            if (preg_match("/png/",$system[1]))
            {
            imagepng($dst_i mg,$filename);
            }
            if (preg_match("/gif/",$system[1]))
            {
            imagegif($dst_i mg,$filename);
            }
            else {
            imagejpeg($dst_ img,$filename);
            }
            imagedestroy($d st_img);
            imagedestroy($s rc_img);
            }


            createthumb($pa th.$imgf,$tpath .$imgf,$tsize,$ tsize);


            Comment

            • Willem Bogaerts

              #7
              Re: File Upload Problem with Thumbnails

              I have a very simple file upload script which creates a thumbnail of
              the file (jpg) upon uploading. This works fine with small images,
              however, if i try to upload a file over about 1mb the thumbnail
              dosen't show. Any ideas ?
              Thanks for any advice.
              Does the full jpg gets uploaded properly? In that case, it is not in the
              upload settings.

              I guess that you use the gd image functions. In that case, note that a
              jpg is a compressed image. To work with it, it must be uncompressed. If
              you want to resample it, you'd probably have both the original and the
              target uncompressed in memory at some point. If you configure PHP to use
              only a limited amount of memory, that memory may be too little, even if
              the uploaded file is not that big. Does increasing the memory limit help?

              Best regards,
              --
              Willem Bogaerts

              Application smith
              Kratz B.V.

              Comment

              • shimmyshack

                #8
                Re: File Upload Problem with Thumbnails

                On 26 Mar, 15:48, Willem Bogaerts
                <w.bogae...@kra tz.maardanzonde rditstuk.nlwrot e:
                I have a very simple file upload script which creates a thumbnail of
                the file (jpg) upon uploading. This works fine with small images,
                however, if i try to upload a file over about 1mb the thumbnail
                dosen't show. Any ideas ?
                Thanks for any advice.
                >
                Does the full jpg gets uploaded properly? In that case, it is not in the
                upload settings.
                >
                I guess that you use the gd image functions. In that case, note that a
                jpg is a compressed image. To work with it, it must be uncompressed. If
                you want to resample it, you'd probably have both the original and the
                target uncompressed in memory at some point. If you configure PHP to use
                only a limited amount of memory, that memory may be too little, even if
                the uploaded file is not that big. Does increasing the memory limit help?
                >
                Best regards,
                --
                Willem Bogaerts
                >
                Application smith
                Kratz B.V.http://www.kratz.nl/
                uploads are slow, i think this is a max execution problem time
                problem, as you script works fine and fast for 2-3MB files, tested on
                15MB file - /then/ the memory was high, but otherwise pretty small.
                2*1024^2 / 30 is about 500kbits/s which is kinda what you expect the
                wrong end of ADSL to be - the upper limit for us poor UK'rs

                Comment

                • shimmyshack

                  #9
                  Re: File Upload Problem with Thumbnails

                  On 26 Mar, 15:48, Willem Bogaerts
                  <w.bogae...@kra tz.maardanzonde rditstuk.nlwrot e:
                  I have a very simple file upload script which creates a thumbnail of
                  the file (jpg) upon uploading. This works fine with small images,
                  however, if i try to upload a file over about 1mb the thumbnail
                  dosen't show. Any ideas ?
                  Thanks for any advice.
                  >
                  Does the full jpg gets uploaded properly? In that case, it is not in the
                  upload settings.
                  >
                  I guess that you use the gd image functions. In that case, note that a
                  jpg is a compressed image. To work with it, it must be uncompressed. If
                  you want to resample it, you'd probably have both the original and the
                  target uncompressed in memory at some point. If you configure PHP to use
                  only a limited amount of memory, that memory may be too little, even if
                  the uploaded file is not that big. Does increasing the memory limit help?
                  >
                  Best regards,
                  --
                  Willem Bogaerts
                  >
                  Application smith
                  Kratz B.V.http://www.kratz.nl/
                  well of course 2*8*1024^2/30 !

                  Comment

                  • callieandmark@yahoo.co.uk

                    #10
                    Re: File Upload Problem with Thumbnails

                    Mx execution time is set at 50000 which i believe is a pretty long
                    time ?

                    Comment

                    • callieandmark@yahoo.co.uk

                      #11
                      Re: File Upload Problem with Thumbnails

                      Oh, and memory limit is 40M


                      Comment

                      • shimmyshack

                        #12
                        Re: File Upload Problem with Thumbnails

                        On 26 Mar, 17:04, "callieandm...@ yahoo.co.uk"
                        <callieandm...@ yahoo.co.ukwrot e:
                        Mx execution time is set at 50000 which i believe is a pretty long
                        time ?
                        yes it is!! Hmmm a mystery!
                        Have you checked the bug database for your version, Im using latest
                        php as module in the latest apache version, there are known bugs for
                        all kinds of functions, if you problem were at around the 2MB mark I
                        would have one in mind from a case I looked at in php4 for instance.

                        All we have done so far is check the process script, which I am
                        assuming you have run independently of the upload script, as you have
                        verified the upload as working with large files.

                        What OS are you on, you could trace the HDD activity with filemon if
                        on windows, that often shows up good stuff.

                        I do note that the way you grab the filename assumes things about them
                        - only one period - which I assume is because you are in total control
                        of their names when uploaded.

                        Comment

                        Working...