Here is my problem. My host changed their security to disable file uploads, so I went to make a little search and found out about the FTP possibilities of php.
Here is the code I used :
Code: Select all
<?php
// variables
$ftpServer = "hostAddress";
$ftpUser = "userID";
$ftpPass = "password";
$finalDir = '/httpdocs/km/tmp/';
$finalFile = $finalDir . $_FILES['userfile']['name'];
$sourceFile = $_FILES['source_file']['tmp_name'];
// Connect and echo result
$ftpConn = ftp_connect("$ftpServer");
$ftpResult = ftp_login($ftpConn, $ftpUser, $ftpPass);
ftp_pasv($ftpConn, true);
if ((!$ftpConn) || (!$ftpResult))
echo "Connection failed<br><br>";
else
echo "Connection succeeded<br><br>";
// upload the file
$ftpUpload = ftp_put($ftpConn, $finalFile, $sourceFile, FTP_BINARY);
// check upload status
if (!$ftpUpload)
echo "FTP upload has failed!";
else
echo "Uploaded $sourceFile to $ftpServer as $finalFile";
// close the FTP stream
ftp_close($ftpConn);
?>Any help?
Thanks,
Simo