logo

CuriousTab

CuriousTab

Discussion


Home Interview Technology Comments

  • Question
  • Explain how to store the uploaded file to the final location.


  • Correct Answer
  • A HTML form should be build before uploading the file The following HTML code is used for selecting the file that is to be uploaded The type attribute of input must be ?file?
    Choose a file to upload:
    At the time of executing uploaderphp, the uploaded file will be stored in a temporary storage are on the webserver An associative array $_FILES['uploadedfile']['name'] is used for uploading The ?name? is the original file that is to be uploaded Another associative array $_FILES['uploadedfile']['tmp_name'] is used for placing the uploaded file in a temporary location on the server and the file should be empty and should exist with the tmp_name The following code snippet is used for uploading the file $target_path = "uploads/"; // the target location of the file $target_path = $target_path basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file " basename( $_FILES['uploadedfile']['name']) " has been uploaded"; } else { echo ?There was an error while uploading the file?; } The function move_uploaded_file()is used to place the source file into the destination folder, which resides on the server If the uploading is successful, the message ?The file filename has been uploaded Otherwise the error message ?There was an error while uploading the file? would be displayed 


  • Technology problems


    Search Results


    • 1. Explain how to send large amounts of emails with php.
    • Discuss
    • 2. Explain Superglobal variables in PHP .
    • Discuss
    • 3. Explain how to work with Permissions in PHP.
    • Discuss
    • 4. What is the difference between $argv and $argc? Give example?
    • Discuss
    • 5. What is the use of $_Server and $_Env?
    • Discuss
    • 6. Explain how to create random passwords.
    • Discuss
    • 7. What type of inheritance that PHP supports? Provide an example.
    • Discuss
    • 8. Explain when to use GET or POST. Provide example for both the ways.
    • Discuss
    • 9. How to set cookies in PHP?
    • Discuss
    • 10. What Is a Session in PHP?
    • Discuss


    Comments

    There are no comments.

Enter a new Comment