Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTML XHTML PHP
I have created the following .php form to upload a file to the locally installed XAMP server's FileZilla server.

File Upload form

 
<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
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 16-Feb-12 6:34am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can use move_uploaded_file[^] to move the temporary file into the path of the FTP server.
  Permalink  
Comments
Chiranthaka Sampath at 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 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 215
1 Suvendu Shekhar Giri 215
2 Andy Lanng 210
3 PIEBALDconsult 190
4 Abhinav S 184
0 Sergey Alexandrovich Kryukov 6,360
1 OriginalGriff 5,878
2 Peter Leow 2,514
3 Maciej Los 2,263
4 Abhinav S 2,249


Advertise | Privacy | Mobile
Web03 | 2.8.150414.1 | Last Updated 16 Feb 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100