Im learning PHP by myself from a book called “PHP the Complete Reference – PHP5.2”
Im currently at Chapter11 FTP, uploading,deleting,makedir etc but have run into a few questions not covered by the book:

According to my textbook this is a simple code to upload to a server:

echo'Could not connect to Server';  
echo'UPLOADING FILE......';
    echo'File Uploaded!';

My Questions:

  1. To which directory will this upload, how will I modify code if i want to upload to directory say public_html/images/myFile.jpg
  2. In the example myFile.php is hardcoded, what if I want user to select a file to upload? Am I correct in assuming you can do something like this:

    <input type="file" name="myFile" value="upload a file" />
    <input type="submit" name="upload" />
        $fileName=$_POST['myFile']; //file is now assigned to var name
        $result=ftp_put($connect,$fileName,FTP_ASCII); //file linked to var name being uploaded
  3. Is this the most efficient secure way?

Thank you for reading

Source: ajax

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.