Forum Moderators: coopster
It seems to me that if I place a POST form on my webpage, and use it to upload a file, it is already using HTTP to upload the file to the TMP directory. It then seems redundant to use FTP to then transfer the file from the TMP directory to my destination folder.
Is it possible to get my form to submit via ftp, instead of HTTP, and then how do I get PHP to process this file upload via ftp? Or am I missing the point? Should I be approaching this in a completely different fashion?
Thanks in advance for any assistance,
Mitch
Once you have the file on your server if you want php to access them you will need to use the fopen and such to get and work with those files.
If you use the usual http action then php will have access to that file before it is uploaded to its final resting place in your file system.
If you have access to the server then you may well be able to write a shell script or some other script to run on the server directly. However php is usually running as an apache module, so is not running on the actual file system of the machine, it is running on apache.
If you are running php from the command line then you may be able to work with these files on the machine (however this is not something I have done, so im guessing :))
<edit>
Just noticed this is your first post, so welcome to Webmaster World :)
[edited by: PHP_Chimp at 9:32 pm (utc) on Dec. 21, 2007]
What your telling me confirms my assumptions. If I used FTP in the action of the form, then I would also have to supply the FTP login information (username/password), or perform some kind of weird encryption, right?
Perhaps you could help me with this instead. have you heard of anything inside of Internet Explore 6.5 or 7, that would block the use of HTTP uploads? I have a few clients that are forced to use Firefox instead - just to make my scripts work. And I can not find anything online that says why IE will not work as well.
Thanks for your help, I really appreciate it.
Mitch
The script works great from my computer (PC and Mac), just some clients that are having trouble. I thought it might be a firewall issue, but then it does not make sense that Firefox would work, and IE would not. So I thought maybe explorer might have some security feature that I could not find.
Thanks,
Mitch
Have you tested the page with IE? As depending on what code you have on the page there may also be issues with IE not actually following the standards and going off doing there own thing.
[edited by: PHP_Chimp at 11:00 pm (utc) on Dec. 21, 2007]
Yah, that is the strange thing. It works in both IE and Firefox on my PC. Just not the client's. I am not using any javaScript to manage or validate the script, just php. I think I am just going to give the client ftp access, have them upload a series of images to the web, and then have a script target/manage those images. It seems easier than trying to work through their permission problems. It will also speed up the processing of the images for their gallery.
Thank you both for your time and support.
Mitch
It then seems redundant to use FTP to then transfer the file from the TMP directory to my destination folder.
Not really, when you consider the file ownership issue. If PHP wants to store the file, the directory will need to be chmod 777 or be owned by apache. Both can be bad.
If I upload the file with a form then use ftp(in the background) to save the file then it will have "normal" ownership(ie, by your normal user).
I think it's a decent solution to a problem that many people have come accross. I sure don't want my directories chmod 777 :)
Marty
P.S. I like to store http/PHP uploaded files in their own directory and go ahead and let apache own that directory(requires root access). Then I can keep permissions safe.