0

I would like to upload images found in a particular folder using FTP in a php file. I am uploading to ftp.photobucket.com, and the folder that the images are found in is dependent on user input. How I would like to do this like the following:

  1. User Enters Folder Name (or chooses from a list) into a form field.

  2. Folder clicks 'Add' button (this is a pre-submit button)

  3. The form parameters are saved in localStorage, and the form is cleared, so that the user can enter new data into the form.

  4. At this point the ftp connection opens in the background, creates the remote folder, and uploads the images (this could happen after submit to prevent multiple executions of the ftp script, but doing it at this point is preferable for time saving purposes)

  5. User enters new data into the form while the images are being uploaded, and repeats as often as he or she chooses.

  6. The user presses submit, and all the form data is posted to a php file, building dynamic file(s) based upon form input.

  7. All the while the ftp process continues to upload silently in the background.

  8. After the ftp process is complete, the user receives notification that his files are available for viewing. He may, of course, view the files before then, but the images will show up as broken links until the upload is finished.

I've got every step of this working except for running the ftp in the background. No matter what I've tried, there has been some error. I have tried various combinations of built-in ftp methods, and I've also tried running a batch script from the file system. Nothing I've found on php.net has provided anything that works.

This is on a Windows box and I have tried the psexec.exe trick(find psexec on this page) to no avail. I have now gotten confused after multiple attempts, and even debugging no longer makes any sense to me. Any help?

[edit]I forgot to add that for the purposes of making this work, this is running on localhost. Getting it to work there at first is what I need now. I'll work out the rest as needed.[/edit]

dgo
  • 3,877
  • 5
  • 34
  • 47
  • Read this : http://www.somacon.com/p395.php and read this : http://stackoverflow.com/questions/265073/php-background-processes – rkosegi Mar 09 '12 at 15:27
  • that "some error" is not an "is" error...it is meant to imply a vast array of different errors and problems. – dgo Mar 10 '12 at 04:17
  • to rkosegi-I've tried everything on the somacon site, but that other link is interesting..I definitely haven't tried that. Will update when I have. – dgo Mar 10 '12 at 04:19

1 Answers1

0

You cannot send directly files to ftp using PHP. You must first upload them locally. And after you can send them to ftp using php. You can use a cron on your web host to execute the php script and send files on ftp. There is many php class to manage ftp : http://www.phpclasses.org/searchtag/ftp/by/package/tag/ftp/

Axel
  • 91
  • 2
  • This is not true. I was able to upload them using built-in ftp methods of php. The only problem was that I had to wait for them to finish loading. I did experience success in uploading them just using ftp_put though. The link is good, but it doesn't appear to have anything that address the issue of running the files in the background. – dgo Mar 10 '12 at 04:14
  • As you say _The only problem was that I had to wait for them to finish loading_ That is why i said _You cannot send directly files to ftp_ and that is why you must store files locally, and send them using the cron later (do a cron every 5min). – Axel Mar 10 '12 at 15:19