Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created the following .php form to upload a file to the locally installed XAMP server's FileZilla server.

File Upload form

HTML
<html>
<body>

<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>

</body>
</html> 


The following will be the Upload Script.

PHP
<?php
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br />";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  echo "Type: " . $_FILES["file"]["type"] . "<br />";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
  }
?> 

But my question is how should I give the script to upload the file to the Filezilla server?
Posted

1 solution

You can use move_uploaded_file[^] to move the temporary file into the path of the FTP server.
 
Share this answer
 
Comments
Chiranthaka Sampath 17-Feb-12 5:57am    
I set the path for the file as the following
$_FILES["file"]["C:\xampp\FileZillaFTP"]$_FILES["file"]["FileZillaFTP"]

but both them have given a error like at the below.

Notice: Undefined index: C: mpp\FileZillaFTP in C:\xampp\htdocs\Mine\upload_file_script.php on line 20
Stored in:
Graham Breach 17-Feb-12 6:35am    
Did you follow the link I posted? There is an example on the page showing what you have to do.

Try this:
move_uploaded_file($_FILES['file']['tmp_name'], 'C:\\xampp\\FileZillaFTP\\' . $_FILES['file']['name']);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900