Question

In: Computer Science

You are required to develop a utility for uploading a file in .rar, .zip and .pdf...

You are required to develop a utility for uploading a file in .rar, .zip and .pdf format using the reusable code of PHP from any online resources. To do this assignment you need to use the FILE element of html forms and on submission the next page should include the php code for completing the operation of file upload. You can use file directories, databases for maintaining your files at your web server along with your web application.

Solutions

Expert Solution

// Front side code
<html>
<head>
    <title>File Form</title>
</head>
<body>
    <form action="done.php" method="post" enctype="multipart/form-data">
        <h3>Upload Any Format</h3>
        <label for="fileSelect">Filename:</label>
        <input type="file" name="file" id="fileSelect">
        <input type="submit" name="submit" value="Upload">
        
    </form>
</body>
</html>
// done.php
<?php
   if(isset($_FILES['file'])){
      $errors= array();
      $file_name = $_FILES['file']['name'];
      $file_tmp =$_FILES['file']['tmp_name'];
      $file_type=$_FILES['file']['type'];
      $file_ext=strtolower(end(explode('.',$_FILES['file']['name'])));
      
      $extensions= array("rar","zip","pdf");
      if(in_array($file_ext,$extensions)=== false)
      {
         $errors[]="extension not allowed, please choose a rar, zip or pdf file.";
      }
      
      if(empty($errors)==true)
      {
         move_uploaded_file($file_tmp,"files/".$file_name);
         echo "Success";
      }
       else
      {
         print_r($errors);
      }
   }
?>

Related Solutions

C# What to submit: One zip file named Ass3.zip This zip must contain one VS 2017...
C# What to submit: One zip file named Ass3.zip This zip must contain one VS 2017 solution named Ass3, which contains one C# Windows Forms App project also named Ass3 and the project contains a default form, Form1.cs and Program.cs. No change should be made in Program.cs, but your Form1 must be designed and implemented to satisfy the following requirements. **Do not submit only a single file of the solution or project. The whole solution folder of VS 2017 must...
Download the following zip file Bag and complete the program. You will need to complete files...
Download the following zip file Bag and complete the program. You will need to complete files MyBag and . MyBag uses the java API class ArrayList as the underline data structure. Using the class variables given, complete the methods of the MyBag class. In your BagHand class you should set appropriate default values for select class variables in the constructor in the add method, use the MyBag object to add a PlayingCard type to the bag and find and set...
. You must use Excel (submit either a pdf, word or Excel file only). . You...
. You must use Excel (submit either a pdf, word or Excel file only). . You must identify the 5 steps (you must address each in detail). Problem: Use the given data to complete a t-test using Excel. Question: Is there a difference in group means between the number of words spelled correctly for two groups of fourth graders? Group Assignment Score 1 3 1 4 1 10 2 14 2 7 2 8 2 10 2 15 2 9...
JAVA Start with the SelectionSort class in the zip file attached to this item. Keep the...
JAVA Start with the SelectionSort class in the zip file attached to this item. Keep the name SelectionSort, and add a main method to it. Modify the selectionSort method to have two counters, one for the number of comparisons, and one for the number of data swaps. Each time two data elements are compared (regardless of whether the items are in the correct order—we're interested in that a comparison is being done at all), increment the comparison counter. Each time...
Instructions: You must complete the questions below. All will be included in a SINGLE PDF file...
Instructions: You must complete the questions below. All will be included in a SINGLE PDF file and turned into Blackboard or handed at the start of class. The due date is specified on the syllabus. Remember, late work is not accepted. You will need an Executive Summary, PowerPoint (one to page/color) and Excel spreadsheet. Be prepared to present your findings in class. Purpose: You must evaluate the various options to ship freight from Asia to the USA. You MUST find...
a)   What is Utility ? Develop a two dimensional model of Total Utility,, and explain the...
a)   What is Utility ? Develop a two dimensional model of Total Utility,, and explain the purpose of this model. b) What is Marginal Utility? Derive it from Total Utility. c) Using utility analysis: if one is economically rational, how does he/she allocate his/her choices ? d) What are indifference curves ? Develop and demonstrate via a two dimensional model. e) Given indifference curves, how is a decision made as to choices ?        Demonstrate.
Since you will be using zip or compressed files; Explain how to zip (compress) and unzip...
Since you will be using zip or compressed files; Explain how to zip (compress) and unzip (uncompress/extract) files. How to extract or uncompress files into a folder. Why do you need to uncompress/extract the files? The importance of knowing about zip/compressed files in digital forensics.
Imagine you are a Senior Officer at the Ministry of Agriculture; you are required to develop...
Imagine you are a Senior Officer at the Ministry of Agriculture; you are required to develop a plan that leads to the efficient utilization of fruits in Guyana by the various stakeholders. Discuss your proposed plan from beginning to end that will contribute to stopping the wastage of fruits in Guyana.
What time was the 'Stuff' zip file created? Last Modified? How many photos exist on the...
What time was the 'Stuff' zip file created? Last Modified? How many photos exist on the drive? Who is the owner, if any? What is the oldest file on the system? What is it's creation date? What time could have the 'Hidden' file been deleted? What content is in the 'Hidden' file? What type of information do you think this is? What is the MD5 hash of the image?
Write a Python script that performs brute force to extract a password protected zip file named...
Write a Python script that performs brute force to extract a password protected zip file named sec2.zip. The password is believed to be associated with one of the dictionary word in the 'wordlist.txt file. a) Paste your code here b) What is the password?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT