Can we check uploaded file Size at client side in GWT by Reading the "header info" of the file

759 views
Skip to first unread message

GWT Groups

unread,
May 11, 2010, 7:18:59 AM5/11/10
to Google Web Toolkit

Hello Friends

I required your views......

" Can we check uploaded file Size at client side in GWT by Reading the
"header info" of the file? "

Please if this is possible than please tell me how to do this. I have
done lot of search on this but not get any thing till now.

Please Help me.....
I am waiting for you response


your Friend
Ankit

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Sripathi Krishnan

unread,
May 11, 2010, 7:52:11 AM5/11/10
to google-we...@googlegroups.com
You can't, and you don't want to.

You can't, because javascript doesn't provide any way to read the contents of a file that is stored locally. You can't read the http header info when the browser submits a multi-part post request. There just isn't a way to do it (unless you are willing to write some Flex code to compile a SWF file for Flash Player 10)..

You don't want to, because client side validation is no validation. It can easily be bypassed. You'd have to perform the check on the server anyways, so why bother with client side validation at all?

--Sri

Frank Harper

unread,
May 11, 2010, 9:04:56 AM5/11/10
to google-we...@googlegroups.com
Because it is a much better user experience to show an error message right away rather than letting the user wait for a long time and then telling him the upload has failed.

Sripathi Krishnan

unread,
May 11, 2010, 9:16:24 AM5/11/10
to google-we...@googlegroups.com
Because it is a much better user experience to show an error message right away rather than letting the user wait for a long time and then telling him the upload has failed.
Agree, its a valid and reasonable use case, just a bit difficult to solve.

--Sri

AndreAgosto

unread,
May 11, 2010, 9:22:47 AM5/11/10
to Google Web Toolkit
Hi Frank, can you help me about upload file?
i saw FileUpload Widget, i put it in a formpanel, but i can't do it
works.. Maybe i did some mistake in servlet side, but i don't know..
Can you send me an example?
Thank you very much

On 11 Mag, 15:04, Frank Harper <frank.har...@gmail.com> wrote:
> Because it is a much better user experience to show an error message right
> away rather than letting the user wait for a long time and then telling him
> the upload has failed.
>
> On Tue, May 11, 2010 at 13:52, Sripathi Krishnan <
>
>
>
> sripathi.krish...@gmail.com> wrote:
> > You can't, and you don't want to.
>
> > You can't, because javascript doesn't provide any way to read the contents
> > of a file that is stored locally. You can't read the http header info when
> > the browser submits a multi-part post request. There just isn't a way to do
> > it (unless you are willing to write some Flex code to compile a SWF file for
> > Flash Player 10)..
>
> > You don't want to, because client side validation is no validation. It can
> > easily be bypassed. You'd have to perform the check on the server anyways,
> > so why bother with client side validation at all?
>
> > --Sri
>
> > On 11 May 2010 16:48, GWT Groups <new.ankitj...@gmail.com> wrote:
>
> >> Hello Friends
>
> >> I required your views......
>
> >> " Can we check uploaded file Size at client side in GWT by Reading the
> >> "header info" of the file? "
>
> >> Please if this is possible than please tell me how to do this. I have
> >> done lot of search on this but not get any thing till now.
>
> >> Please Help me.....
> >> I am waiting for you response
>
> >> your Friend
> >> Ankit
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Google Web Toolkit" group.
> >> To post to this group, send email to google-we...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/google-web-toolkit?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-web-toolkit?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/google-web-toolkit?hl=en.

Frank Harper

unread,
May 11, 2010, 10:15:10 AM5/11/10
to google-we...@googlegroups.com
Sorry, I can't add anything to what Sripathi already said. I haven't implement this myself.

kozura

unread,
May 11, 2010, 4:49:03 PM5/11/10
to Google Web Toolkit
You don't have to wait for the server to download the entire file to
give a response, you can get it right away and send back an error
immediately; just the cost of a quick round trip to the server.

As suggested in many similar posts, gwt-upload is a pretty good
solution for file uploads in GWT: http://code.google.com/p/gwtupload/.

On May 11, 7:04 am, Frank Harper <frank.har...@gmail.com> wrote:
> Because it is a much better user experience to show an error message right
> away rather than letting the user wait for a long time and then telling him
> the upload has failed.
>

Jérémie

unread,
May 11, 2010, 9:54:41 AM5/11/10
to Google Web Toolkit
You can use HTML5 File API through JSNI

https://developer.mozilla.org/en/Using_files_from_web_applications

However it's a new feature and few browsers support it...
Reply all
Reply to author
Forward
0 new messages