File Upload - <input type=file>

R

RWK

I'm trying to figure out how to verify that the file trying to be uploaded
exists. On my page if I type in the name of a file that doesn't exist it
get's uploaded as a file with 0 bytes.

When using Yahoo mail when I type in a non-existent file and try to upload
it will come back and tell me "Invalid File" but I can't figure out how they
are doing it.

Help would be appreciated!
RWK
 
D

Dietmar Meier

RWK said:
I'm trying to figure out how to verify that the file trying to be
uploaded exists. On my page if I type in the name of a file that
doesn't exist it get's uploaded as a file with 0 bytes.

For security reasons there should be no chance using client side
JS to check anything in the client's file system.
When using Yahoo mail when I type in a non-existent file and try to
upload it will come back and tell me "Invalid File" but I can't
figure out how they are doing it.

Maybe they simply reject all empty files. Try to upload an existing
file with 0 bytes and see if there's a difference to a non-existing
file. Anyway, they check it on the server, not on the client.

ciao, dhgm
 
R

RWK

You're awsome dude... I knew about the restrictions with accessing the local
file system from script so that's why I was stumped as to how Yahoo was
doing it... checking for 0 bytes on the server... easy enough!

Thanks!
 
G

Grant Wagner

RWK said:
I'm trying to figure out how to verify that the file trying to be
uploaded
exists. On my page if I type in the name of a file that doesn't exist
it
get's uploaded as a file with 0 bytes.

When using Yahoo mail when I type in a non-existent file and try to
upload
it will come back and tell me "Invalid File" but I can't figure out
how they
are doing it.

I just ran a small test. It's pretty obvious that when you click Attach
Files the file is actually uploaded (and most likely tagged with a
message id so Yahoo! knows which message it "belongs to"). So the server
is detecting that the file is 0 bytes and complaining.

This was verified by -touch-ing a file and attempting to attach it, I
got the same "Invalid File" message.

In other words, the detection is not happening on the client (nor can it
in a cross-platform, cross-browser way).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top