Can I use JavaScript to upload only part of a selected file? -


i have web app needs process csv files. prior processing, i'd give user option "preview" how plan treat each column. in case, if file has hundreds of thousands of lines, i'd first process first dozen or so.

it should pretty easy send portion of file on server. there, can whatever it. trick determining how many bytes of file necessary. if don't care how many "columns" contained in portion sent server, can pick byte offset, let's 1000 bytes.

so, have file. presumably using browser uses file api. in such browser, can handle on file via datatransfer object drop event or via the files property of <input type="file"> element. let's assume have file object.

first, grab first 1k of file:
var myfilepart = myfile.slice(0, 999);

myfilepart blob. can send blob server via xhr2: xhr.send(myfilepart)


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -