Good all the time of day, gentlemen.

Form, enter data, submit button - everything works. I want to add input in which you can select a file to load. Yes, yes, the Internet is full of examples, but I will ask something non-standard. I want to write in the input only the address of the file (we do not load the file itself). And after entering the address (i.e., if filled), the hunt is a little lower to make another input (up to 7-10 units). (Eats but without reloading the page.)

Dear, tell me how to implement it?

ps actually here already in the form where I transfer there already and I will think how to load the file, and I will be glad to tips

pps iframe - please do not offer.

Added after 2 hours:

 // подключаем JQ // ждем нажатия ссылки у id=text1 <script type="text/javascript"> $(document).ready(function () { $("a").click(function() { var id = $(this).attr('id'); $.ajax({ url: "if.php", type: "POST", data: {id: id}, success: function(text) { $("#text1").append(text); } }); }); }); </script> // в место инпута пишу это <div id="text1"> <a href="#" id="1">Добавить</a> </div> // создаем if.php - здесь будем добавлять input'ы для файлов // и на этом я остановился // echo "1"; // при нажатии на ссылку выше - просто добавляются единицы без перезагрузки 

5 hours later: In general , I perceive criticism adequately, and I will be happy with the decision. If I do not find it, I will post my decision. Let not perfect, but it is optimized, which can be customized for yourself (namely, this is the main minus of examples from Ineta)

  • 3
    Well, adding a couple of fields is not a problem. And why " think how to download a file " if you can safely download them through a hidden iframe? Or, as they say, we are not looking for easy ways? - Deonis
  • 3
  • Deonis, I don't know AJAX well, that's why I asked. Specter, added the visibility and clarity of the solution given in the example - I would like to correct my own, but now, looking at the example, I think how to get the necessary 1kb 8- from the 250kb code (-Sergey
  • Yes, it is difficult when Dial-Up ... You fight for every KB. ))) The most interesting thing is that reducing the code by a dozen KB. and rejoicing, rubbing the handles, absolutely do not pay attention to the fact that the graphics, in comparison with the scripts, are ten times heavier;) And in fact, you don’t need to know ajax, because ajax does not support file uploads. More precisely, the technology is - " XMLHttpRequest 2 ", but here's the blessing: today, it is supported by one Chrome, and then with glitches. - Deonis
  • Yes, especially if you consider that mobile devices have Dial-UP speed, you have to take into account not your Wishlist, but the custom one. And unfortunately, the appearance of the above solution will be harder and longer to fix than if writing from scratch - sergey

1 answer 1

If you just enter the path to the file in the file system does not work. Neither any script, browser or server (if you pass it the path) will not be able to access the file. This is done for security purposes. The user must manually select the file in the dialog box. This is the standard. Imagine what would happen if the sites themselves could copy files from your computer.