bubbasheeko posted on 2008-11-14 19:45:00 #
I can't seem to figure this out. Using the code you published I keep receiving the error:
error code 6 (my handler identifies the error)
The code:
if (isset($_POST['file_name'])) {
if (!empty($_FILES['file_name']['name'])) {
$ch = curl_init();
$localfile = $_FILES['file_name']['tmp_name'];
$fp = fopen($localfile, 'r');
curl_setopt($ch, CURLOPT_URL, 'ftp://loginname@domain.com:password@ftp.domain.com/'. $directory_result['directory'] . '/' . $_FILES['file_name']['name']);
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
curl_exec ($ch);
$error_no = curl_errno($ch);
curl_close ($ch);
if ($error_no == 0) {
$error = 'File uploaded succesfully.';
} else {
$error = 'There was an error uploading your file. Please refer to error code '. $error_no . '.';
}
} else {
$error = 'Please select a file.';
}
}
I want to think it is a problem with the user name - the ftp account is a sub account that requires the @ symbol.
Any thoughts, any more detail needed let me know :)
Kevin
The most popular forum posts:
Comments / discussions
Olaf posted on 2008-11-14 19:49:59 #
maybe the FTP address is wrong? or the directory doesn't exists? or the user has no rights to write?
bubbasheeko posted on 2008-11-14 20:08:33 #
I verified that I could connect to the server through shell access to the server and through windows explorer. It works through both.
It just won't connect.
I have verified the output of the variables and they are correct. I created a variable for the directory (ftp://loginname@domain.com:password@ftp.domain.com/'. $directory_result['directory'] . '/' . $_FILES['file_name']['name'])
This the output:
ftp://username@domain.com:password@ftp.domain.com/directory/file.txt
If I connect to the ftp server with the username and login it brings me to directory that has only one directory - in the case of the example - directory is the only folder here.
Olaf posted on 2008-11-14 20:12:13 #
then it should be the first @ sign...
what happens if you put this row into your browser/explorer bar?
ftp://username@domain.com:password@ftp.domain.com/directory/file.txt
bubbasheeko posted on 2008-11-14 22:43:11 #
I received:
Windows cannot find 'ftp://username@domain.com:password@ftp.domain.com/directory'
Check the spelling and try again.
(I don't have a file on there as of yet)
I did try using the main ftp account - the account's root account - it connected using the above format (ftp://login:password@domain.com).
What can I do to have it accept that there is an @ symbol in the user name?
Olaf posted on 2008-11-15 06:24:12 #
I think nothing the @ character is very important in this address.
why not use the main account? you can put this script into a .htaccess protected directory, so no one else than you is able to access the script
bubbasheeko posted on 2008-11-15 15:47:00 #
I was thinking the same thing. I couldn't think of anything to bypass the @. It's too bad I wasn't on a Windows server...could have switched the first ampersand to %40 and that would have worked.
I didn't really want to use the 'root' account to do this, but it is more apparent that I will have to. I would use the .htaccess file to protect this directory, but I cannot because of the nature of the system - it is for uploading presentations for organizations so it will be accessed by a few different organizations - many being a little computer illiterate. So I have had to go with a special session key and a php login form to protect this part of the system and make a bit easier for those illiterate users.
Thanks for you assistance on this. Great script!
bubbasheeko posted on 2008-11-15 16:09:27 #
I guess I am not quite done with the need of your assistance.
The largest file that will be uploaded will be set at 20MB.
I just attempted to upload an 18MB file and received error 26. Which is a read error or read call back error. If you know, how can I resolve this?
It's funny that there are several pages out there that show the error codes, but none that really show how to resolve them - or what the cause may be.
Thanks again!
Kevin
Olaf posted on 2008-11-15 16:25:03 #
maybe some memory limit?
I use the script on linux systems with much bigger files (> 100mb)
I think that a lot of your problems are related to a non professional webserver...
bubbasheeko posted on 2008-11-15 17:02:27 #
LOL...my bad...I hadn't changed my file upload size to 25MB. Fixed.