Easy A
Would you like to react to this message? Create an account in a few clicks or log in to continue.


 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

Share
 

 restrict file upload size

View previous topic View next topic Go down 
AuthorMessage
~Chair~
Member
Member
~Chair~

Posts : 13
Join date : 2011-04-18

restrict file upload size Empty
PostSubject: restrict file upload size   restrict file upload size EmptyThu Jun 23, 2011 8:14 am

Hello all,

In JSP / HTML, I want to restrict the size of file being uploaded.

<input type="file" name="myfile"/>

If the size of file more than a specific size say 5MB, i want to give mesage to the user. I don't want to wait till the file gets uploaded to server and then validate the file size. I am looking for client side validation. Can it be done using scripting language or any other way?

I need a solution for this in Internet Explorer. I got a solution using ActiveX control:
var myFSO = new ActiveXObject("Scripting.FileSystemObject");
var filepath = document.getElementById('myfile').value;
var thefile = myFSO.getFile(filepath);
var sizeInBytes = thefile.size;

But ActiveX controls are not allowed in our application. Is there any alternative way for this?

Please suggest the possible ways.. Thanks!!
Back to top Go down
Float
Member
Member
Float

Posts : 2
Join date : 2011-05-11

restrict file upload size Empty
PostSubject: Re: restrict file upload size   restrict file upload size EmptyThu Jun 23, 2011 8:15 am

activex is the only way to do it in IE that i know of...
Back to top Go down
~Chair~
Member
Member
~Chair~

Posts : 13
Join date : 2011-04-18

restrict file upload size Empty
PostSubject: Re: restrict file upload size   restrict file upload size EmptyThu Jun 23, 2011 8:15 am

Thanks rnd me. Is it possible using Applets?
Back to top Go down
~Chair~
Member
Member
~Chair~

Posts : 13
Join date : 2011-04-18

restrict file upload size Empty
PostSubject: Re: restrict file upload size   restrict file upload size EmptyThu Jun 23, 2011 8:16 am

I've used applets and it worked.

jFileUpload solved this issue:
http://www.jfileupload.com/products/jfileupload/ => download link
http://jupload.sourceforge.net/howto-customization.html => documentation
* http://www.jfileupload.com/products/...tion_http.html => config params

maxsize- This parameter identify the maximum size of the uploaded file. It prevents the user to upload too big files.

thanks to the forum for the suggestions.
Back to top Go down
Sponsored content




restrict file upload size Empty
PostSubject: Re: restrict file upload size   restrict file upload size Empty

Back to top Go down
 

restrict file upload size

View previous topic View next topic Back to top 
Page 1 of 1

 Similar topics

-
» file size help
» Where is a free site to upload my swf Header file?
» C: Read from file and write to file
» Help with adding an image upload field
» optimal MB of size per minute of .swf movie

Permissions in this forum:You cannot reply to topics in this forum
Easy A :: restrict file upload size Edit-trash Useless :: Trash-