Hi,
I can uplaod a file to a folder of choice using php and MySQL. Can anyone tell me how to download a file from a local folder on my machine? I’m using WAMP so I’d say it’s more moving the file than downloading it but either way would do.
Here’s my upload code:
[php]
<?php $allowedExts = array("doc", "docx", "pdf"); $temp = explode(".", $_FILES["file"]["name"]); $extension = end($temp); if (((($_FILES["file"]["type"] == "application/pdf") || ($_FILES["file"]["type"] == "application/msword")) && ($_FILES["file"]["size"] < 2000000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . ""; } else { echo "Upload: " . $_FILES["file"]["name"] . "
"; echo "Type: " . $_FILES["file"]["type"] . "
"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB
"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "
"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } header("Location: student_content.php"); // redirect back ?>
[/php]
Thanks.