NetTalk Central

Author Topic: Applying File Uploads limits  (Read 5431 times)

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Applying File Uploads limits
« on: May 13, 2009, 12:29:34 PM »
Hi,
I need to restric the size and quantity of images uploads from a user.
Once the image is uploaded, in which WebHandler method must I check the file size to delete it?
The file is renamed in the Rename file method, before parent call.

Thanks
Alberto
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Applying File Uploads limits
« Reply #1 on: May 13, 2009, 09:09:09 PM »
.HandleFile

Before the parent call you can check the length of the file (it's one of the parameters.)
The Parent call saves the file to disk.
After the parent call you can move the file, or do anything else with it that you like.

Cheers
Bruce


Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Applying File Uploads limits
« Reply #2 on: May 14, 2009, 02:37:50 AM »
Thanks,

Now I can return before the parent call and the file will not upload.

But... how could I inform the user that situation?

Alberto



-----------
Regards
Alberto

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: Applying File Uploads limits
« Reply #3 on: May 14, 2009, 05:16:50 PM »
Alberto,

If you check the file size after the file is uploaded, you are sort of defeating the purpose since you normally want to warn a user of a large file to avoid unexpected delays while the very large file is uploaded.

The client side would be the best place for this, however javascript cannot access the filesystem and the only other way i know of doing it is to embed an ActiveX object into javascript and now-a-days browsers will warn you and some won't support ActiveX at all.

Perhaps some else knows a way around this? Otherwise you are stuck with server side only.

Regards
Bill

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: Applying File Uploads limits
« Reply #4 on: May 14, 2009, 05:23:26 PM »
Just stumbled over a very cool Flash control for uploading files with full source code, so if you are into ActionScript you might like to look at http://digitarald.de/project/fancyupload

I'm definitely going to add it to a few projects of mine.

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Applying File Uploads limits
« Reply #5 on: May 15, 2009, 06:19:14 AM »
Hi,
I have a table to register the name and full path name of images. I fill it qith a browse/form
The browse displays the image name and the image itself.
The form is used to fill the image name and upload the image.

I check the file size in the WebHandler HandelFile method before the Parent call to avoid the upload of big images, usng the following code:

  if p_len>Maxlen#
     return Level:Notify
  end

The problem is that when an image is rejected by the code, the image is not uploaded but the register of the table is saved.

How can I fix it?

Thanks
Alberto
-----------
Regards
Alberto

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Applying File Uploads limits
« Reply #6 on: May 19, 2009, 01:59:51 AM »
Please Bruce...

The problem is that when an image is rejected by the code,
the image is not uploaded
but the register of the table is saved.
And I dont know how to let the user know Ive rejected the image.

How can I fix it?

Thanks
Alberto
-----------
Regards
Alberto

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Applying File Uploads limits
« Reply #7 on: May 22, 2009, 07:03:10 AM »
Bruce, any idea please?

Thanks
Alberto
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Applying File Uploads limits
« Reply #8 on: May 24, 2009, 09:49:25 PM »
Right-click on the procedure
goto Source
look for where the field is set
and clear it.

Or where you discard the image, use SETVALUE to change the contents of the filename.

The code is all there (generated into your app, and in netweb.clw, so read it to see what it is doing.

Cheers
Bruce