Results 1 to 5 of 5
Thread: restrict file size before upload
- 06-14-2011, 11:54 AM #1
Member
- Join Date
- Jun 2011
- Posts
- 3
- Rep Power
- 0
restrict file size before upload
Hello all,
In JSP / HTML, I want to restrict the size of file being uploaded. I've <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 need client side validation. Can it be done using scripting language or any other way?
I need a solution for this in Internet Explorer. There is already a solution I got 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 in advance!!
----
Poli reddy
- 06-14-2011, 12:47 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
That would be javascript and, as far as I'm aware, security would normally prevent javascript from pulling such information from the file system.
Though, since it's Javascript, you'd probably get more accurate answers from a Javascript forum.
- 06-15-2011, 08:22 AM #3
Member
- Join Date
- Jun 2011
- Posts
- 3
- Rep Power
- 0
Thanks Tolls. I checked in javascript forums.. there is no solution using javascript other than ActiveX control. Is it possible using Applet??
- 06-15-2011, 09:35 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
The Applet would need to be signed to allow access to the client machine so it can find the file size.
- 06-20-2011, 08:57 AM #5
Member
- Join Date
- Jun 2011
- Posts
- 3
- Rep Power
- 0
Thanks Tolls.. I've used applets and it worked.
jUpload soved this issue:
File upload applet - HTTP/FTP upload - JFileUpload => download link
JUpload - File Upload Applet (HowTo - customize it) => documentation
*JFileUpload - HTTP upload parameters => 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 too..!!
Similar Threads
-
Auto generated email and restrict user to access only specific link or file.
By Chinnu55 in forum Advanced JavaReplies: 6Last Post: 05-29-2011, 12:14 PM -
File upload
By bekir in forum Java ServletReplies: 2Last Post: 04-08-2011, 03:17 PM -
how to restrict the size of the window in swt
By chakribobby in forum SWT / JFaceReplies: 2Last Post: 06-09-2010, 03:31 PM -
:large file upload to server(chunk upload)
By tommy_725 in forum NetworkingReplies: 0Last Post: 10-16-2009, 12:21 AM -
File Upload
By ShoeNinja in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 11-09-2007, 10:09 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks