Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you simulate a realistic file upload time on your local machine using <input type="file"/>?

I'm working on a web page with a file upload form that uploads a file via ajax (with the jquery.form plugin and an updating <progress> bar). I am using MAMP, and since a file I upload is just being copied from one location on my computer to another, the upload time is too quick to see the progress bar in action, even if the file is huge.

I remember seeing a screencast where the presenter made some change to his local env that slowed down the upload process but the specific screencast escapes me...

like image 545
AndyPerlitch Avatar asked Jun 26 '12 18:06

AndyPerlitch


People also ask

How do you append files in input type file multiple before uploading?

You could add a new <input type="file"> whenever you finished uploading the previous files and hide the previous input. This way you keep adding a new input every time you want to add more files and prevent the previous input from being overwritten. And it doesn't require you to use AJAX.

How do you specify a file type to upload?

Acceptable file types can be specified with the accept attribute, which takes a comma-separated list of allowed file extensions or MIME types. Some examples: accept="image/png" or accept=".png" — Accepts PNG files. accept="image/png, image/jpeg" or accept=".png, .jpg, .jpeg" — Accept PNG or JPEG files.

How can create upload file in HTML?

The <input type="file"> defines a file-select field and a "Browse" button for file uploads. To define a file-select field that allows multiple files to be selected, add the multiple attribute. Tip: Always add the <label> tag for best accessibility practices!


1 Answers

You need to install libapache2-mod-bw

Then in your virtualhost config set:

<virtualhost *:80>
    ...
    BandWidthModule On 
    ForceBandWidthModule On
    BandWidth all 80000
</virtualhost>

This will set a 80 KB/s limit on uploads.

like image 178
dmck Avatar answered Oct 12 '22 23:10

dmck