Aaron Posted June 29, 2003 Share Posted June 29, 2003 I'm trying to use the php ftp functions, but I can't seem to get them to work. Is the PHP ftp enabled on the server? I'd really appreciate it if someone who has already used the php ftp functions would share their code cuz I'm really not getting anywhere. Thanks, Aaron Quote Link to comment Share on other sites More sharing options...
freddy Posted June 29, 2003 Share Posted June 29, 2003 Maybe you could add your code here so we can see what's wrong? Quote Link to comment Share on other sites More sharing options...
Aaron Posted June 29, 2003 Author Share Posted June 29, 2003 I'm actually pursuing two different methods, first is the move_uploaded_file() method, and next is the ftp_put method(). I'm gonna outline what I know below, just in case there is a flaw in my logic somewhere. In the first case, I use a standard html form, with an input with type=file: ><FORM ACTION='ftp.php?submit=1' METHOD='POST' ENCTYPE="MULTIPART/FORM-DATA"> <INPUT TYPE="FILE" NAME="file"> <BUTTON TYPE="SUBMIT">UPLOAD</BUTTON> </FORM> Once the user clicks on the Upload button, I run this script: >$upload_dir = "public_html/uploads/" $filename = $_FILES['file']['name']; $tempname = $_FILES['file']['tmp_name']; move_uploaded_file($tempname, $upload_dir . $filename); I basically just copied the example off of the php manual for handling file uploads: PHP Manual: Handling File Uploads I tried this locally on my laptop with IIS and PHP, and it works, but it doesn't work on my TCH site. I figure that the problem is either that I need the full path to my account, OR this method is just not supported by TCH. So I then tried PHP's ftp methods. I didn't even use any kind of form: >$ftp_connection = ftp_connect($ftp_server); $login = ftp_login($ftp_connection, $ftp_username, $ftp_password); ftp_put($ftp_connection, "/public_html/uploads/file.doc", "C:\file.doc", FTP_BINARY); That's it. Again, the code is pretty much lifted off the PHP manual. The problems I see here are that I might just need the full path to my folder on the TCH server, or my reference to "C:\file.exe" is just wrong ... I only know the basic differences between the Linux and Windows directory structures ("\" vs. "/", Windows has drive letters), so I might just be missing something there. Thanks for any help on this guys! I'd also appreciate it if the forum moderators could chime in on whether ftp is enabled on the php, and whether or not I do need the full path. Aaron Quote Link to comment Share on other sites More sharing options...
freddy Posted July 4, 2003 Share Posted July 4, 2003 Instead of move_uploaded_file() try using copy(). www.php.net/copy() Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.