Closed
Bug 506362
Opened 16 years ago
Closed 16 years ago
Use JavaScript to test file uploads before the client sends the POST request
Categories
(addons.mozilla.org Graveyard :: Public Pages, enhancement)
addons.mozilla.org Graveyard
Public Pages
Tracking
(Not tracked)
VERIFIED
FIXED
5.0.9
People
(Reporter: mozilla.bugs, Assigned: u278084)
Details
(Whiteboard: [AMO508Testday])
Attachments
(2 files, 1 obsolete file)
|
4.04 KB,
patch
|
wenzel
:
review+
|
Details | Diff | Splinter Review |
|
35.04 KB,
image/png
|
Details |
If a user tries to upload a *.tif file or other unsupported format, the file is posted and then rejected.
Would is save time and server load to reject the file with a javascript regular expression before the upload begins?
| Reporter | ||
Updated•16 years ago
|
Whiteboard: [AMO508Testday]
Updated•16 years ago
|
OS: Windows XP → All
Summary: Use Javascript to test file uploads before the client sends the POST request → Use JavaScript to test file uploads before the client sends the POST request
Comment 1•16 years ago
|
||
Sounds like a good idea. Can we test the file size too? Probably.
Severity: normal → enhancement
Hardware: x86 → All
Updated•16 years ago
|
Assignee: nobody → cdolivei.bugzilla
Updated•16 years ago
|
Target Milestone: --- → 5.0.9
Checks for proper file name extension and checks file size (gecko only. If you know of a webkit/trident method, I'd love to hear it!).
Attachment #395245 -
Flags: review?(clouserw)
Updated•16 years ago
|
Attachment #395245 -
Flags: review?(clouserw) → review-
Comment 3•16 years ago
|
||
Comment on attachment 395245 [details] [diff] [review]
v1
Looks pretty good, though:
>+// Returns the largest file you can upload to the server, in bytes.
>+function getMaxFileSize() {
>+ $size = ini_get('upload_max_filesize');
>+ switch (substr($size, -1)) {
>+ case 'M' :
>+ return (int)$size * 1024;
>+ default :
>+ return $size; // assume bytes
>+ }
>+}
>+
wouldn't M be $size * 1024 * 1024?
Comment 4•16 years ago
|
||
Trident can apparently use ActiveX for this purpose, though I am not sure we want this: http://www.kavoir.com/2009/01/check-for-file-size-with-javascript-before-uploading.html
In fact, I'd vote for "no". We decided once upon a time to ask for Gecko+JavaScript in the Dev CP, and try to degrade gracefully where reasonable. Not checking file sizes pre-upload for IE users seems graceful enough to me.
Thanks Wenzel. You are right, it is 1024 * 1024.
I didn't know about the ActiveX method for IE, but for some reason I was surprised. But I agree; dealing with it on the server side is graceful enough for IE, or any other browsers for that matter.
Attachment #395245 -
Attachment is obsolete: true
Attachment #395500 -
Flags: review?
Attachment #395500 -
Flags: review? → review?(fwenzel)
Comment 6•16 years ago
|
||
Comment on attachment 395500 [details] [diff] [review]
v2. now more right
I tried it and it wfm, good job.
Attachment #395500 -
Flags: review?(fwenzel) → review+
Comment 7•16 years ago
|
||
Thanks everyone. r49610
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
| Reporter | ||
Comment 8•16 years ago
|
||
Can we apply this to the profile user page where a user image is uploaded? (Since that is what I meant to have this apply to and just didn't make it clear ;) ). Thank you though for fixing it on the developer page, since I didn't catch it there.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 9•16 years ago
|
||
I'd like QA to check this for 5.0.9 so I'm re-resolving this bug. Tanner, can you file another bug and put it in the 5.1 milestone for our next push? (If you can't do the milestone I can after you file). Thanks.
Status: REOPENED → RESOLVED
Closed: 16 years ago → 16 years ago
Resolution: --- → FIXED
| Reporter | ||
Comment 10•16 years ago
|
||
Filed Bug 511932 and set milestone to 5.1.
Verified FIXED; I tried .tif, .doc, .ppt, .gif, .jpeg, .png.
Status: RESOLVED → VERIFIED
Updated•10 years ago
|
Product: addons.mozilla.org → addons.mozilla.org Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•