Announcement

Collapse
No announcement yet.

Multi Upload (Size Limit) ?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multi Upload (Size Limit) ?

    Hello,

    Is there anyway to limit the size (in MB's) of uploaded images to store in the mysql database?

    Right now it seems like any size goes?

    Any help is appreciated.

    Thanks.

  • #2
    It's set as part of the overall application settings under (left hand side) - Application | Settings | Maximum file size (right pane, settings section near the bottom)

    Comment


    • #3
      Thanks!

      Is the entry there referring to MB's or Kilo-Bytes?

      So if you enter 3 does that mean 3MB's ?

      Comment


      • #4
        Ok....now I'm confused?

        I have set the Maximum File Size = 3 as described by "adz1111" above.

        I assume that is in MB's ?

        Regardless of what I set it to it doesn't seem to reject a image upload of 5.5MB that I'm testing with?

        I thought the multi-upload would reject the the image if it was over the set 3MB limit ?

        Can some one point me in the right direction here?

        What am I doing wrong?

        Comment


        • #5
          I read somewhere it's bytes, but when I tested with just a "1", it still uploads any size! Suspect this is a bug :-(

          Comment


          • #6
            Anyone from Scriptcase support comment on this ?

            Is this a bug?

            Comment


            • #7
              Hello Everyone.

              I'm hoping someone here can give the answer to this.

              I've spent a ton of time with SC support and it must be a language barrier as I could never get the answers I required.

              It seems that SC "Maximum File Size" - (Application, Settings) really doesn't do anything according to support.

              SC support is telling me that if I want to limit a file upload (3MB Max) through "Multi_upload" that I need to set my "php.ini - (upload_max_filesize = 3M).

              I get what there saying but if you try it out it doesn't work. If your try as an example to upload a 5MB image the progress bar will progress all the way to the end and just stop and nothing else happens?

              I get why this happens as somewhere in the background PHP hangs because it doesn't know what to do with the %MB file as its only allowing 3MB max.

              Errors must be happening in the background but SC doesn't handle them.

              SC support says I need to implement extra code to catch the error and use "sc_message_error" to display an error to the user.

              They suggested using the "onBeforeInsert" and "onBeforeUpdate" events.

              That's fine but they could not show me how to accomplish this.

              Does anyone here show an example of how to do this?
              Last edited by instore; 08-07-2014, 04:51 PM.

              Comment


              • #8
                Originally posted by instore View Post
                Hello Everyone.

                I'm hoping someone here can give the answer to this.

                I've spent a ton of time with SC support and it must be a language barrier as I could never get the answers I required.

                It seems that SC "Maximum File Size" - (Application, Settings) really doesn't do anything according to support.

                SC support is telling me that if I want to limit a file upload (3MB Max) through "Multi_upload" that I need to set my "php.ini - (upload_max_filesize = 3M).

                I get what there saying but if you try it out it doesn't work. If your try as an example to upload a 5MB image the progress bar will progress all the way to the end and just stop and nothing else happens?

                I get why this happens as somewhere in the background PHP hangs because it doesn't know what to do with the %MB file as its only allowing 3MB max.

                Errors must be happening in the background but SC doesn't handle them.

                SC support says I need to implement extra code to catch the error and use "sc_message_error" to display an error to the user.

                They suggested using the "onBeforeInsert" and "onBeforeUpdate" events.

                That's fine but they could not show me how to accomplish this.

                Does anyone here show an example of how to do this?

                I've done it!!!! (i guess)... you have to evaluate (in bits 1MB= 1024000) the size of the uploaded file. an example can be:

                $Size=filesize($this->SC_IMG_FieldName)// note that $this->SC_IMG_ is PHP SC Code and fieldName is the name of an image field

                then you have the way to evaluate file sizes... i hope to help with u

                Comment


                • #9
                  Thanks Welectronic !!

                  Can you show me a working example of what you did?

                  I would really appreciate it.

                  Comment


                  • #10
                    Anyone able to show a working example?

                    It would be a big help to alot of users.

                    Comment


                    • #11
                      Code to handle file size

                      I will try to do my best :/
                      • First, create a field named ImageField, type Image(filename). No more configuration needed.
                      • Second, in the onValidate event paste the next code:




                      Code:
                      $Size=1024;//Size in KB
                      $FieldName=$this->SC_IMG_ImageField;
                      $NamF='uploaded file';// just for message error handling, usefull when u have many images in separated fields
                      
                      if (isset ($FieldName))
                      	{	
                      	 $error_test    = filesize($FieldName) > ($Size*1000);    // Error test
                      	 $error_message = 'The size of '.$NamF.' must be less than '.$Size.'KB.'; // Error message
                      
                      	 // Redirection
                      	 if ($error_test)
                      	  {
                      	 	sc_error_message($error_message);
                      		sc_error_exit();// note that many procedures can be disabled using  the exit error procedure
                      	  }
                      	}

                      I hope it can help

                      Comment


                      • #12
                        This is great as a workaround - however, ideally, SC should fix the field where you specify a max filesize so that it actually works rather than that field currently being ignored for some reason!

                        Comment


                        • #13
                          Awesome welectronic but i'm using "image (Database)".

                          Does that make a difference as I get the error "Undefined property: form_tb_byob_orders_collapse_apl::$SC_IMG_PP_image s" when I click the save record button and it tries to validate?

                          Your help is appreciated!

                          Comment


                          • #14
                            Hello instore,

                            note that an image in a database field is not a file, it's only a group of bytes that must be decoded, i suggest to refer this page to get the file size of a bolb field http://www.virendrachandak.com/techt...blob-in-mysql/.

                            SC doesn't have support for file handling tooooo bad, but is a good tool for RAD.

                            Comment


                            • #15
                              hi welectronic, and thanks for this solution, it works with me on image (file name) as described


                              however, i have this field "Not Required" so if left empty it gives this error:


                              Code:
                              Undefined property: form_new_apl::$SC_IMG_ImageField

                              any idea!?



                              Mike
                              Last edited by MikeDE; 08-25-2014, 11:19 AM.

                              Comment

                              Working...
                              X