Jump to content

Ftp Form help


Recommended Posts

Ftp Form help-- when the file uploads to the server, it doesnt upload the full file to the server? When it uploads a 1mb file only uploads 330k!

 

 

the form is the code below in a file named = ftpupload.htm :

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

 

<body>

<code> <form enctype="multipart/form-data" action="upload.php" method="post">

  <p><br>

    <input type="hidden" name="MAX_FILE_SIZE" value="200000000" />

    <br>

Send this file:</p>

  <p>

  <input name="userfile" type="file" />

  </p>

  <p><br>

    <input type="submit" value="Send File" />

    <br>

      </p>

</form></code>

</body>

</html>

 

the php is the code below in a file named = upload.php :

 

<?php

// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead

// of $_FILES.  In PHP versions earlier than 4.0.3, use copy() and

// is_uploaded_file() instead of move_uploaded_file.

$ftp_server = "mysite.com";

$ftp_user = "name";

$ftp_pass = "pass";

 

// set up a connection or die

$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");

 

// try to login

if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {

echo "Connected as $ftp_user@$ftp_server\n";

} else {

echo "Couldn't connect as $ftp_user\n";

}

 

$remote_file = $_FILES['userfile']['name'];;

//I used these for debugging

echo $_FILES['userfile']['name'];

echo "<br>";

echo $_FILES['userfile']['type'];

echo "<br>";

echo $_FILES['userfile']['size'];

echo "<br>";

echo $_FILES['userfile']['tmp_name'];

echo "<br>";

echo $_FILES['userfile']['error'];

echo "<br>";

 

//v important this one as you have to use the tmp_file created for the actual upload

$file = $_FILES['userfile']['tmp_name'];

if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {

echo "successfully uploaded $file\n";

} else {

echo "There was a problem while uploading $file\n";

}

 

// close the connection

ftp_close($conn_id);

?>

 

 

thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.