I have been googling the whole day trying everything I can find, but nothing works. I'm starting to get desperate.
I'm trying to make a script that can upload a file to my ftp account, but so far I've not been able to get it working.
I'm getting these errors:
Warning: ftp_put(): Opening data channel for file transfer. in C:\xampp\htdocs\AA\dwsite\ftptest\up.php on line 49
Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\AA\dwsite\ftptest\up.php on line 49
This is the code I'm using:
<?php
if (isset ( $_FILES ['be_file'] )) {
$file_size = $_FILES ['be_file'] ['be_file'];
$file_type = $_FILES ['be_file'] ['type'];
$source_file = $_FILES ['be_file'] ['tmp_name'];
$destination_file = $_FILES ['be_file'] ['name'];
//ftp details
$ftp_server = 'ip of ftp';
$ftp_port = 'port number';
$ftp_user_name = 'username';
$ftp_user_pass = 'pass';
// set up basic connection
$conn_id = ftp_connect ( $ftp_server, $ftp_port );
ftp_pasv ( $conn_id, true );
// login with username and password
$login_result = ftp_login ( $conn_id, $ftp_user_name, $ftp_user_pass );
// upload a file
if (ftp_put ( $conn_id, $destination_file, $source_file, FTP_BINARY )) {
echo "successfully uploaded $source_file\n";
exit ();
} else {
echo "There was a problem while uploading $source_file\n";
exit ();
}
// close the connection
ftp_close ( $conn_id );
echo "Success";
}
?>
<html>
<body>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="file" /> <input type="submit" />
<ul>
<li>Sent file: <?php echo $_FILES['be_file']['name']; ?>
<li>File size: <?php echo $_FILES['be_file']['size']; ?>
<li>File type: <?php echo $_FILES['be_file']['type']?>
</ul>
</form>
</body>
</html>