| | |
Error in uploading file via ftp server
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2008
Posts: 13
Reputation:
Solved Threads: 0
i currently working on web based ftp system where this system will upload and retrieve file from ftp server in red hat linux 9.0.
here is the php cording for the upload file:-
1.upload.html
2.upload.php
when i execute this code it give me the following error:-
Connected to 10.1.45.21, for user sanya
Warning: ftp_put(forum.txt) [function.ftp-put]: failed to open stream: No such file or directory in D:\AppServ2\AppServ\www\FTP\test\upload.php on line 32
FTP upload has failed!
Can any one help me plz..
here is the php cording for the upload file:-
1.upload.html
php Syntax (Toggle Plain Text)
<html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form action="upload.php" method="post" enctype="multipart/form-data" name="form1" > <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>user name </td> <td><input name="username" type="text" id="username"></td> <td> </td> </tr> <tr> <td>password</td> <td><input name="password" type="password" id="password"></td> <td> </td> </tr> <tr> <td>File name </td> <td><input type="file" name="file"></td> <td> </td> </tr> <tr> <td><input type="submit" name="Submit" value="Upload"></td> <td> </td> <td> </td> </tr> </table> </form> </body> </html>
php Syntax (Toggle Plain Text)
<html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php //$ftp_server=$_POST['server']; $ftp_server = "10.1.45.21"; $ftp_user_name=$_POST['username']; $ftp_user_pass=$_POST['password']; $source_file=$_FILES['file']['name'];// retrieve name of the file to be uploaded $destination_file=$source_file; // make a connection to the ftp server $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id , $ftp_user_name , $ftp_user_pass); // check connection if((!$conn_id)||(!$login_result)){ echo "FTP connection has failed!" ; echo "Attempted to connect to $ftp_server for user $ftp_user_name" ; exit; }else{ echo "Connected to $ftp_server, for user $ftp_user_name" ; } // upload the file $upload = ftp_put($conn_id,$destination_file,$source_file,FTP_ASCII ); // check upload status if(!$upload){ echo "FTP upload has failed!" ; }else{ echo "Uploaded $source_file to $ftp_server as $destination_file" ; } // close the FTP stream ftp_close($conn_id); ?> </body> </html>
when i execute this code it give me the following error:-
Connected to 10.1.45.21, for user sanya
Warning: ftp_put(forum.txt) [function.ftp-put]: failed to open stream: No such file or directory in D:\AppServ2\AppServ\www\FTP\test\upload.php on line 32
FTP upload has failed!
Can any one help me plz..
Last edited by cscgal; Sep 22nd, 2008 at 12:51 pm. Reason: Added code tags
•
•
Join Date: Sep 2008
Posts: 13
Reputation:
Solved Threads: 0
i did as you said but it still does not work. here is the cording that i add in upload.php file before close the ftp connection:-
// upload the file
//$upload = ftp_put($conn_id,$destination_file,$source_file,FTP_ASCII );
if (move_uploaded_file($source_file, "/home/admin")) {
print "Received {$_FILES['file']['name']} - its size is {$_FILES['file']['size']}";
} else {
print "Upload failed!";
}
// upload the file
//$upload = ftp_put($conn_id,$destination_file,$source_file,FTP_ASCII );
if (move_uploaded_file($source_file, "/home/admin")) {
print "Received {$_FILES['file']['name']} - its size is {$_FILES['file']['size']}";
} else {
print "Upload failed!";
}
•
•
Join Date: Sep 2008
Posts: 13
Reputation:
Solved Threads: 0
if i use the cording below replace the cording that i post previously:-
$destination_dir = 'home/admin';
$destination_file = $uploaddir . basename($_FILES['file']['name']);
if (move_uploaded_file($source_file, $destination_file)) {
print "Received {$_FILES['file']['name']} - its size is {$_FILES['file']['size']}";
} else {
print "Upload failed!";
}
it give me a successful message showing that the file upload successfully. but if i try to search the file in /home/admin dir in linux....there were no files there.is my upload file works and where do i check for the uploaded files. help me plz..
$destination_dir = 'home/admin';
$destination_file = $uploaddir . basename($_FILES['file']['name']);
if (move_uploaded_file($source_file, $destination_file)) {
print "Received {$_FILES['file']['name']} - its size is {$_FILES['file']['size']}";
} else {
print "Upload failed!";
}
it give me a successful message showing that the file upload successfully. but if i try to search the file in /home/admin dir in linux....there were no files there.is my upload file works and where do i check for the uploaded files. help me plz..
![]() |
Similar Threads
- Internal Server Error (Perl)
- Questions For WebDevelopment =) (HTML and CSS)
- 500 Internal Server Error - with a twist (Perl)
- FTP error in Dreamweaver (Site Layout and Usability)
- modify script (Perl)
- Dreamweaver MX uploading problem (Site Layout and Usability)
- ftplib and the retrbinary() command (Python)
Other Threads in the PHP Forum
- Previous Thread: convert integer number to float number
- Next Thread: PHP/JavaScript Problem...
| Thread Tools | Search this Thread |
.htaccess alerts apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code convert cron curl database dataentry date display duplicates dynamic echo email emptydisplayvalue error execute explodefunction file files firstoptioninphpdroplist folder form forms function functions google hack href htaccess html htmlspecialchars image include insert ip javasciptvalidation javascript joomla keywords limit link login mail matching menu methods mlm multiple mysql network object oop paypal pdf php problem query radio random recursion recursive redirect remote script search securephp server sessions shot sms source space sql subscription syntax system table tutorial tutorials update upload url validator variable video web youtube





