Using ftp functions to upload a file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
HiddenS3crets
Forum Contributor
Posts: 119
Joined: Fri Apr 22, 2005 12:23 pm
Location: USA

Using ftp functions to upload a file

Post by HiddenS3crets »

I need to create a file upload script so people can upload files from their computer to my server, but I cannot use $_FILES because move_uploaded_file() violates the safe mode restrictions, so I need to use ftp functions instead to upload it. I've tried using ftp_put(), but it isn't working.

Is ftp_put() the right function to use? The source code i've looked at from various tutorials has provided no help. Possibly one of you could? :(
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

the ftp functions will not work in your situation. They are to upload / download files from the server to another, ftp server. If you need to allow people to upload files from their machines to your server, then you're going to have to use the $_FILES[] array if you plan to do it via HTML. Other options would include writing something in flash or java that would allow for uploading files.
HiddenS3crets
Forum Contributor
Posts: 119
Joined: Fri Apr 22, 2005 12:23 pm
Location: USA

Post by HiddenS3crets »

Damn, thought so... The problem is that I can't use $_FILES because of the safe mode restrictions. I cannot turn it off because I don't host my own server, thus I can't restart Apache to save the safe mode settings.

I don't think there's another way to turn it off. I also tried putting in the .htaccess file this line:
php_admin_flags safe_mode off

But then I just get Internal Server Errors on any pages in the directory with the .htaccess file.

Do you know of any other way to turn off safe mode?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

usually you can ask your host to do that for you.
Post Reply