I program a file sharing service to restore gaps in knowledge and learn a lot of new things.

Gentlemen, again many questions:

  1. How to make the user not to look, but download a picture, text, when clicking on a link? How this is done in Google Mail, for example.
  2. I didn’t find a way to check the file size before uploading to the server, selected via the HTML file (form). The method recognized by the solution in the past to my question, it turns out, does not work in all browsers.
  3. How to add the variable value to the clipboard in javascript, jquery? Is it possible?
  4. Is it possible to somehow realize the scale of the process of uploading a file to the server via javascript, jquery? Or just flash and similar technologies, such as silverlight?

I want from you not a ready-made code, but manuals, solutions and suggestions that google, read. Thank you.

  • four
    It has become interesting, will there be fools to answer you? .... - Gorets
  • 2
    I will answer the first question only :) send the header corresponding via header () - johniek_comp
  • > The method that was recognized as a solution in the past to my question, it turns out, does not work in all browsers. Only in IE below version 10 does not work. But you must admit, this is much better than without checking at all. - Ilya Pirogov

4 answers 4

@Gorets , what's wrong ?!

one)

header('Content-Disposition: attachment; filename="filename"'); 

2)

No There are no universal ways, and those that can help you easily deceive. Restrictions put everything on the server, respectively, keep the extra 10-20 maximum volumes that you can manage to fill in during the interaction with the server. Example: the maximum request time is a minute, the maximum input speed is 100 Mbps. Bottom line: you should be free ~ 8-15 gig.

3)

Cookies. Fortunately, JS cannot work with the clipboard (ActiveX does not count).

four)

There are no universal ways. Some browsers can do this, like a fox, but not all.

  • one
    > keep the extra 10-20 maximum volumes that you can manage to fill up during the interaction with the server. Why? client_max_body_size — when trying to send a file larger than this value, nginx will simply break the connection. With all the desire to download any gigabytes will not succeed. - Ilya Pirogov 1:01 pm
  • Yep But notice that 1) there are a lot of customers. (This is what a reserve is made for so that, if you wish, at the same time the uploading customers do not clog the disk). 2) nginx - also from the server side 3) ... it is not configured for everyone - knes
  • 3) is done somehow with crutches through flash. But in general, somewhere I definitely saw an addition to the buffer, cross-browser, although on crutches - Sh4dow

Immediately clicked on "send to server" and did not choose anything.

Files of this type are not allowed to be uploaded to the server, compress it into a .rar or into a .zip archive.

And then closed the page.

  • one
    Renamed exe to zip. Loaded. Trollface - knes
  • Yes, not exe so well loaded there. but the fact that I renamed php to zip and now crawling on the server is cool! Sew holes in your file sharing. - Artem
  • I renamed php to zip // I didn’t want to write this in order not to compromise. >. < - knes pm
  • Well, what can we do now! ^ _ ^ We need to initially check everything, and not show those who sometimes suffer from file renaming and find interesting holes. - Artem
  • 2
    @Shrek, and explain to the dark person (to me)> but what I renamed php to zip and now crawling around the server How can this happen? Does he somehow allow you to directly access (GET, POST) files that are uploaded? Or am I just talking nonsense and the matter is something else? - avp

Well, the first "problem" can be solved much more flexibly with the help of the magic .htaccess:

  AddType application/octet-stream .rar .doc .mov .avi .pdf .xls .mp4 

As you know, this is a list of files that will be offered to be saved, not opened in the browser. But do not have to send heders every time.


The fourth can be solved on HTML5 progress.

  • Super. <progress value = "22" max = "100"> </ progress> Such Lyalok can be assembled in five minutes from divs. One problem: Even if I manage every second requests for a server to find out the size of the already loaded content (value), I DO NOT know max. So the thing is pretty useless in light of the question. - knes

Regarding the fourth question - http://php.net/manual/en/session.upload-progress.php