Carga de PHP ftp en segundo plano

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]

preguntado el 09 de marzo de 12 a las 14:03

that "some error" is not an "is" error...it is meant to imply a vast array of different errors and problems. -

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. -

1 Respuestas

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/

respondido 09 mar '12, 19:03

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

Como usted dice 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

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.