Hi' all
I have a strange problem when uploading files from a form to my ftp site.
Here is my code:
[PHP]<?php
$myFile = $_FILES['file']; // This will make an array out of the file information that was stored.
$file = $myFile['tmp_name']; //Converts the array into a new string containing the path name on the server where your file is.
$myFileName = $_POST['MyFile']; //Retrieve file path and file name
$myfile_replace = str_replace('\\', '/', $myFileName); //convert path for use with unix
$myfile = basename($myfile_replace); //extract file name from path
$destination_file = "/webshop/".$myfile; //where you want to throw the file on the webserver (relative to your login dir)
// connection settings
$ftp_server = "ftp.printline.dk"; //address of ftp server (leave out ftp://)
$ftp_user_name = "xxxxxxxx"; // Username
$ftp_user_pass = "xxxxxxxx"; // Password
$conn_id = ftp_connect($ftp_server); // set up basic connection
// login with username and password, or give invalid user message
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or die("<h1>You do not have access to this ftp server!</h1>");
$upload = ftp_put($conn_id, $destination_file, $file, FTP_BINARY); // upload the file
if (!$upload) { // check upload status
echo "<h2>FTP upload of $myFileName has failed!</h2> <br />";
}
/*
// try to delete $file
if (ftp_delete($conn_id, $destination_file)) {
echo "$destination_file has been deleted!\n";
} else {
echo "Could not delete $destination_file!\n";
}
*/
ftp_close($conn_id); // close the FTP stream
?>[/PHP]
And this works okay, but when i upload files that has a size between about 1 MB - 2MB i get this error:
Warning: ftp_put(): Connection closed; transfer aborted. in D:\Webs\printline-webshop.eu\httpdocs\konto\placeorder.php on line 15
FTP upload of Y:\\Medie-Design\\printlineweb\\www\\downloads\\alphastar_Pr ocess_summary.zip has failed!
But the file goes into my folder on my ftp site.
When i then upload files biger than 2 MB i get this error:
FTP upload of Y:\\Medie-Design\\printlineweb\\www\\downloads\\artikel1.zip has failed!
And the files doesn't go into my ftp site.
My webprovider has an upload limit size of 2MB in their php ini file but i can't see this as a problem when i upload to my ftp site, which is located on a local windows 2003 server. OR is this a problem..????
Does anyone know why this happens, and maybe give me a solution to work around this...?
Thanks in advance!