+ Reply to Thread
Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By Livewire

Thread: Maximum File Size Upload

  1. #1
    zzzj_2812 is offline x10Hosting Member zzzj_2812 is an unknown quantity at this point
    Join Date
    Nov 2010
    Posts
    10

    Lightbulb Maximum File Size Upload

    Hello all!

    I would like some help with a performance issue: the upload of very large files.

    Here's the issue: users are able to upload avatars on a site that I am currently building. Currently, the server will check if the avatar is larger than an allowed file size, and if it is too large, the avatar will not be saved. However, this is not satisfactory for me. The server has to spend a lot of time receiving the file, only to tell the user that its not allowed. Is there any way to either:

    1) Check the file size on the client side, and keep the user from uploading it, or
    2) Change some configuration setting so that the server will not even start to upload files that are too large?

    I know you can change some settings in php.ini to accomplish the second, but we don't have access to php.ini. Does anyone have any suggestions?

  2. #2
    fomalhaut is offline x10Hosting Member fomalhaut is an unknown quantity at this point
    Join Date
    Aug 2009
    Location
    South of France near Arles
    Posts
    91

    Re: Maximum File Size Upload

    Hello

    First, you can add this tag as first one in the form tag, that limits the size on the client side:
    HTML Code:
    <input type="hidden" name="MAX_FILE_SIZE" value="200000" />
    Naturaly, the value "200000" is an example !

    On the server side, you can control the size by the $_FILES function:
    PHP Code:
    if ($_FILES['fileName']['error']==2) {
      
    $Tmsg 'Too big file (it must not be greater than '.$_POST['MAX_FILE_SIZE'].' octets)';
      ...
    display this information or do what you want
    "fileName" is an example, too. It's the name of the file in the form tag (<input type='file', name='fileName'... />).

    But I don't know really if the system on the server knows immediatly the size or if it begins the load !
    Try it and eventually see the PHP documentation.

    Good year
    Last edited by fomalhaut; 01-04-2012 at 03:50 AM.

  3. #3
    Livewire's Avatar
    Livewire is offline Abuse Compliance Officer Livewire is a glorious beacon of lightLivewire is a glorious beacon of light
    Join Date
    Jun 2005
    Location
    Behind a keyboard.
    Posts
    8,998

    Re: Maximum File Size Upload

    @fomalhaut: If you're checking filesize on the server-side (as in via php), that's server-side, it has to upload the file first.

    @OP: about the best I can recommend (I have no actual examples) is either a Javascript uploader or a similar Flash based one - both would run on the client computer and could check the filesize prior to the upload, but I've not actually looked for these in the past since I haven't needed them, so I'm not sure of any good ones to recommend.
    fomalhaut likes this.


    TOS breakers will be suspended regardless of race, creed, national origin, hair color, or favorite food. Thanks for your understanding!

  4. #4
    ellescuba27 is online now x10 Sophmore ellescuba27 is an unknown quantity at this point
    Join Date
    Sep 2011
    Posts
    151

    Re: Maximum File Size Upload

    I don't believe x10hosting allows for file storage

  5. #5
    garrette is offline x10Hosting Member garrette is an unknown quantity at this point
    Join Date
    Jan 2012
    Posts
    27

    Re: Maximum File Size Upload

    Quote Originally Posted by ellescuba27 View Post
    I don't believe x10hosting allows for file storage
    That would be correct if he was storing these files for download. The terms of service state that this can't be used to host scripts such as torrentflux. It also states that it is alright to host files, as long as they have to do with the website. Now if this website gets too large and overuses it's share of file storage, then that's a whole different situation.

    What he is asking doesn't violate the ToS, since he is not hosting these files for download, they deal with his site.

  6. #6
    zzzj_2812 is offline x10Hosting Member zzzj_2812 is an unknown quantity at this point
    Join Date
    Nov 2010
    Posts
    10

    Re: Maximum File Size Upload

    @ellescuba27: that would be a little nuts, since pretty much every site of any type needs some type of file storage.
    @fomalhaut: thanks for the suggestions, but I already have server-side checks such as that in place
    @Livewire: I did a little googling about a JS uploader, but apparently JS is not able to access the file system, and as such, can't check the file size. I would like to avoid using flash if possible. Any other suggestions?

+ Reply to Thread

Similar Threads

  1. Replies: 1
    Last Post: 10-22-2011, 01:34 PM
  2. Maximum file size ftp
    By mass.donati88 in forum Free Hosting
    Replies: 1
    Last Post: 05-24-2011, 10:46 PM
  3. Maximum file upload size directive in php
    By stpvoice in forum Free Hosting
    Replies: 4
    Last Post: 04-05-2009, 11:49 AM
  4. Which the maximum size for file?
    By balada in forum Free Hosting
    Replies: 1
    Last Post: 08-07-2008, 02:41 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers