Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Task: Create a set of php programs to allow users of the web site to upload vari

ID: 3545297 • Letter: T

Question

Task: Create a set of php programs to allow users of the web site to upload various files to our server. Details:
  • use the standard "php upload" routine
  • be sure to allow for file size up to 300 megabytes
  • limit files to type: txt, pdf, dxf, png
  • store the files in a subdirectory: .tmpFiles  [be sure to use the "dot" in front of the file name
  • rename the files when uploaded to a unique name, in case two users happen to upload the same file, but retain the extension [txt, pdf, dxf, png]
  • add a "list" feature to show what files are in the temp folder
  • add one "bell or whistle" that comes to mind as a "nice to have" feature of this exercise
Task: Create a set of php programs to allow users of the web site to upload various files to our server. Details:
  • use the standard "php upload" routine
  • be sure to allow for file size up to 300 megabytes
  • limit files to type: txt, pdf, dxf, png
  • store the files in a subdirectory: .tmpFiles  [be sure to use the "dot" in front of the file name
  • rename the files when uploaded to a unique name, in case two users happen to upload the same file, but retain the extension [txt, pdf, dxf, png]
  • add a "list" feature to show what files are in the temp folder
  • add one "bell or whistle" that comes to mind as a "nice to have" feature of this exercise
Create a set of php programs to allow users of the web site to upload various files to our server. Details: use the standard "php upload" routine be sure to allow for file size up to 300 megabytes limit files to type: txt, pdf, dxf, png store the files in a subdirectory: .tmpFiles [be sure to use the "dot" in front of the file name rename the files when uploaded to a unique name, in case two users happen to upload the same file, but retain the extension [txt, pdf, dxf, png] add a "list" feature to show what files are in the temp folder add one "bell or whistle" that comes to mind as a "nice to have" feature of this exercise

Explanation / Answer

This is upload.php file that you need for your program:


<?php

$allowedExts = array("txt", "pdf", "dxf", "png");

$temp = explode(".", $_FILES["file"]["name"]);

$extension = end($temp);

if ((($_FILES["file"]["type"] == ".tmpFiles/txt")

|| ($_FILES["file"]["type"] == ".tmpFiles/pdf")

|| ($_FILES["file"]["type"] == ".tmpFiles/dxf")

|| ($_FILES["file"]["type"] == ".tmpFiles/png")

&& ($_FILES["file"]["size"] < 300000)

&& in_array($extension, $allowedExts))

{

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"];

}

}

else

{

echo "Invalid file";

}

?>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote