FTP address - ftp9.Jabry.com
Username - florinsteaua
Password - florinsteaua
Click here for larger image
Figure 1. Setting the FileZilla Site Manager by providing the corresponding information
Status: Resolving address of ftp9.Jabry.com
Status: Connecting to 67.208.91.118:21...
Status: Connection established, waiting for welcome message...
Response: 220 users9 V2 WS_FTP Server 5.0.4 (0)
Command: USER florinsteaua
Response: 331 Password required
Command: PASS ************
Response: 230 user logged in
Command: SYST
Response: 215 UNIX
Command: FEAT
Response: 500 illegal command
Status: Connected
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/florinsteaua" is current directory
Command: TYPE I
Response: 200 Type set to IMAGE.
Command: PASV
Response: 227 Entering Passive Mode (67,208,91,118,14,129).
Command: LIST
Response: 150 Opening ASCII data connection for directory listing
Response: 226 transfer complete
Status: Directory listing successful
Click here for larger image
Figure 2. Using the FileZilla client to see the main folder of the site
<html>
<body>
<form action="ftp.php" method="post" enctype="multipart/form-data">
<div>
<label for="upload">Select file</label>
<input name="upload" type="file" />
<input type="submit" name="Submit" value="Upload" />
</div>
</form>
</body>
</html>
Click here for larger image
Figure 3. The HTML form used to browse the file that will be uploading
<?php
if (isset($_POST['Submit'])) {
if (!empty($_FILES['upload']['name'])) {
//Initialize a cURL session
$ch = curl_init();
$localpicture = $_FILES['upload']['tmp_name'];
$fp = fopen($localpicture, 'r');
//Set the URL for cURL to work with
curl_setopt($ch, CURLOPT_URL, 'ftp://florinsteaua:florinsteaua@ftp9.Jabry.com/'.$_FILES['upload']['name']);
// Sets the TRUE option to prepare for an upload
curl_setopt($ch, CURLOPT_UPLOAD, TRUE);
//Sets the input file for the transfer
curl_setopt($ch, CURLOPT_INFILE, $fp);
//Sets the size of the file to be sent, in bytes
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localpicture));
//Executing the upload
curl_exec ($ch);
$error_no = curl_errno($ch);
curl_close ($ch);
if ($error_no == 0) {
$error = 'File uploaded succesfully.';
} else {
$error = 'File upload error.';
}
} else {
$error = 'Please select a file.';
}
echo $error;
}
?> $error_no=0 then everything worked fine ( you can find all the error corresponding to their number of the error here and you should get the message : 'File uploaded successfully.', like in the next figure:
Click here for larger image
Figure 4. The FTP OK message listed into the browser
Click here for larger image
Figure5. The site structure and content after uploading the picture_to_upload.jpg picture