0

I am trying to connect to a server via php and write a PDF file to a folder that I dynamically create. This is the code I am using:

<?php
$ftp_server = "[server ip]";
$ftp_user_name = "[username]";
$ftp_user_pass = "[password]";

// set up basic ssl connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
if ($login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass)){

mkdir('/home/luke/public_html/pdfs/kmhllc/', 0777, true);
}else{
echo "Connection Failed";
}
// close the ssl connection
ftp_close($conn_id);
?>`

The code connects to the server just fine but it can't write to the folder even though it has 0777 permissions on the server.

Sal Vadala
  • 17
  • 3

1 Answers1

1

use ftp_mkdir not mkdir to create a directory on the ftp server.

dvhh
  • 4,724
  • 27
  • 33
  • Thanks for the help. That command would make sense however I keep getting an error: ftp_mkdir(): Can't create directory: No such file or directory in /home/forms/public_html/tester.php – Sal Vadala Mar 16 '15 at 15:36
  • it means that the parent directory do not exists check for the existence of `/home/luke/public_html/pdfs` and the parent directories – dvhh Mar 17 '15 at 01:06
  • http://php.net/manual/en/function.ftp-mkdir.php#112399 the first comment on the page indicate how to perform the recursive creation, other than that also check the case of your directory name – dvhh Mar 17 '15 at 01:07