We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,991 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

upload file using php ftp

Hi! there is some problem in uploading file. some one help me and please make corrections in code.

//// upload_form.html


<html>
<body>

<form enctype="multipart/form-data" action="upload_file.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

</body>
</html>




///////upload_file.php

<?php

$ftp_server = "ftp.myhome1.site40.net";
$ftp_username   = "a3877054";
$ftp_password   =  "lms604";

//setup of connection
$conn_id = ftp_connect($ftp_server) or die("could not connect to $ftp_server");

//login
if(@ftp_login($conn_id, $ftp_username, $ftp_password))
  {
      echo "conectd as $ftp_username@$ftp_server\n";

}
 else {

      echo "could not connect as $ftp_username\n";
}

$file = $_FILES["file"]["name"];
$remote_file_path = "/public_html/".$file;

ftp_put($conn_id, $remote_file_path, $file, FTP_ASCII);

ftp_close($conn_id);

echo "\n\nconnection closed";




?>
2
Contributors
3
Replies
1 Week
Discussion Span
2 Years Ago
Last Updated
4
Views
saqib_604
Newbie Poster
15 posts since Jul 2010
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Is there anything in the error logs or are you getting any error messages on screen?

tiggsy
Junior Poster
131 posts since Jul 2009
Reputation Points: 16
Solved Threads: 10
Skill Endorsements: 2

thanks it is solved. but there is still a problem of ftp_get() function. can u give some example?

saqib_604
Newbie Poster
15 posts since Jul 2010
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Check that your host allows file gets. Some don't, which is why I don't use it any more.

tiggsy
Junior Poster
131 posts since Jul 2009
Reputation Points: 16
Solved Threads: 10
Skill Endorsements: 2

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0607 seconds using 2.68MB