Php Ftp

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?<br /><br />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.<br /><br />Thanks,<br />Aaron<!--content-->
Maybe you could add your code here so we can see what's wrong?<!--content-->
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.<br /><br />In the first case, I use a standard html form, with an input with type=file:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><FORM ACTION='ftp.php?submit=1' METHOD='POST' ENCTYPE="MULTIPART/FORM-DATA"><br />         <INPUT TYPE="FILE" NAME="file"><br />         <BUTTON TYPE="SUBMIT">UPLOAD</BUTTON><br /></FORM><!--c2--></div><!--ec2--><br /><br />Once the user clicks on the Upload button, I run this script:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$upload_dir = "public_html/uploads/"<br />$filename = $_FILES['file']['name'];<br />$tempname = $_FILES['file']['tmp_name'];<br />move_uploaded_file($tempname, $upload_dir . $filename);<!--c2--></div><!--ec2--><br /><br />I basically just copied the example off of the php manual for handling file uploads: <a href="http://us3.php.net/manual/en/features.file-upload.php" target="_blank">PHP Manual: Handling File Uploads</a><br /><br />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.<br /><br />So I then tried PHP's ftp methods. I didn't even use any kind of form:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$ftp_connection = ftp_connect($ftp_server);<br />$login = ftp_login($ftp_connection, $ftp_username, $ftp_password);<br />ftp_put($ftp_connection, "/public_html/uploads/file.doc", "C:\file.doc", FTP_BINARY);<!--c2--></div><!--ec2--><br /><br />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.<br /><br />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.<br /><br /><br />Aaron<!--content-->
Instead of move_uploaded_file() try using copy().<br /><br /><br />www.php.net/copy()<!--content-->
 
Back
Top