JavaScript Upload local file from webbrowser directly to FTP server, bypass the web server upload local file to s3,upload local file to server

I want to upload user uploaded file (from website <form>) to my FTP server, in which I want to bypass the server and want that file should be sent to FTP server directly. Is it possible using PHP or JavaScript?

In current scenario when I upload file using HTML form and PHP to Apache server, the file is stored in /tmp/ directory and then I can transfer it to FTP location. But this takes double time in uploading as the filed is first uploaded to Apache server and then to the FTP server.

Cloud servers run this way, where Apache server can be by passed and file can be posted directly to cloud server)

I want this so that we can overcome the HTTP part and want to upload large file to FTP server without getting any HTTP upload restrictions.

Answer:1

The HTML form tag does not support the FTP.


You cannot use PHP either as it cannot access local (as of webbrowser) files.


So JavaScript is the only likely solution.

The XMLHttpRequest class theoretically supports FTP:

Despite its name, XMLHttpRequest can be used to retrieve any type of data, not just XML, and it supports protocols other than HTTP (including file and ftp).

But in reality it probably does not.
See the accepted answer to What is the syntax to do a cross-domain XMLHTTPREQUEST to an FTP server?

So actually, there does not seem to be any solution readily available.


If possible, run a web server on the FTP server host and send the files using the web server (HTTP).


Another alternative is to stick with the transferring via your web server, but in a streaming mode. Post your file to the web server. Make the handling script continuously read the incoming data and have them continuously uploaded to the FTP server.

You won't save a bandwidth, but you will save time (as both transfers happen nearly in parallel).

Using the ftp_fput with a handle to the standard input should do (didn't try).

Answer:2

I'm using an ajax call to append rows dynamically to a table using jQuery. I would like the button generated in each row to display a modal with data specific to the items in that particular row. I ...

I'm using an ajax call to append rows dynamically to a table using jQuery. I would like the button generated in each row to display a modal with data specific to the items in that particular row. I ...

  1. materialize modal initialize
  2. materialize modal

I need to upload an from a clients computer to the server running the code. It wouldn't be hard if those files were less than 2mb, but since the file may be a video as well, I'm not sure how to ...

I need to upload an from a clients computer to the server running the code. It wouldn't be hard if those files were less than 2mb, but since the file may be a video as well, I'm not sure how to ...

  1. upload file image php
  2. upload file image laravel
  3. upload file image html
  4. upload file image using ajax
  5. upload file image codeigniter
  6. upload file image javascript
  7. upload file image bootstrap
  8. upload file image
  9. upload file image jquery
  10. upload file image angular
  11. upload file image only
  12. upload file image react
  13. upload file image php mysql
  14. upload file image c#
  15. upload file image python
  16. upload file image icon
  17. upload file image angularjs
  18. upload file image type
  19. upload file image yii
  20. upload file image input

I am trying to create a table with non repeating random letters (uppercase only) using JavaScript. Someone posted an answer, but it was deleted before I got a chance to ask: 1) Why is there a var x ...

I am trying to create a table with non repeating random letters (uppercase only) using JavaScript. Someone posted an answer, but it was deleted before I got a chance to ask: 1) Why is there a var x ...

Probably not the best question ever, but I have a doubt here. Is there any difference writing this: var myFunction = function myFunction () {}; myFunction.instance = null; and this: var myFunction ...

Probably not the best question ever, but I have a doubt here. Is there any difference writing this: var myFunction = function myFunction () {}; myFunction.instance = null; and this: var myFunction ...

  1. javascript anonymous function with parameters
  2. javascript anonymous function this
  3. javascript anonymous function vs named
  4. javascript anonymous function return
  5. javascript anonymous function arrow
  6. javascript anonymous function example
  7. javascript anonymous function call
  8. javascript anonymous function scope
  9. javascript anonymous function return object
  10. javascript anonymous function callback
  11. javascript anonymous function syntax
  12. javascript anonymous function async
  13. javascript anonymous function arrow syntax
  14. javascript anonymous function es6
  15. javascript anonymous function closure
  16. javascript anonymous function object
  17. javascript anonymous function as argument
  18. javascript anonymous function onclick
  19. javascript anonymous function use
  20. javascript anonymous function foreach