Hi,i tried my level best but couldn't create a PHP Script to Upload Files to FTP (To Uploadify) from my local computer.

Any Help..! If anyone can share the Code/ Script?

Dani AI

Generated

This thread from asked for a PHP script to upload files to FTP. recommended a front-end tool (a drag/drop uploader) and correctly pointed out that browser uploads should normally go to a server endpoint over HTTP, not directly to FTP. The usual, robust pattern is: client -> HTTP POST -> server-side PHP validates/sanitizes and stores the file -> if required, server pushes the file to an FTP/SFTP endpoint. That keeps credentials off the client and gives a place to enforce size/type limits, virus scanning, and logging.

A minimal server-side workflow looks like: accept the multipart POST with PHP, check $_FILES and $_FILES[...]['error'], use move_uploaded_file to a safe folder, then (only if needed) transfer the saved file to the remote host with a server-side FTP or SFTP call. Example transfers can use PHP's FTP functions (ftp_connect / ftp_put) or a secure option such as ssh2 or a pure-PHP library like phpseclib. Store credentials outside the webroot and use passive mode for FTP when behind NAT/firewalls.

Troubleshooting checklist: confirm file_uploads=On, raise upload_max_filesize and post_max_size if needed, inspect $_FILES['...']['error'], ensure the web process can write the upload folder, enable ftp_pasv for passive FTP, check server and firewall ports, and prefer FTPS/SFTP over plain FTP for production. For reference on server handling and transfer functions see the PHP manual on file uploads, move_uploaded_file, and FTP functions, and the phpseclib project for SFTP.

Recommended Answers

All 2 Replies

I use DropzoneJS and I’m quite happy with it. It’s quite popular as well.

commented: Can you please elaborate? Like the steps, i am bit new to this. +0

Firstly, the best way to upload files via PHP is not via FTP.

Check out https://www.dropzone.dev/

If you want to upload files to your own server (which it seems like that's what you're trying to do), use https://www.dropzone.dev/js/

If you want everything to be handled for you (including hosting the files), use https://www.dropzone.dev/plus/ (but it costs money)

Documentation is at https://docs.dropzone.dev/getting-started/installation/stand-alone

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.