please i need a php script to download file from a folder in WAMPSERVER, i have a script to upload file which is working properly but when i upload i want to also download file. this is my upoad script
PHP script to download file
1
please i need a php script to download file from a folder in WAMPSERVER, i have a script to upload file which is working properly but when i upload i want to also download file.
this is my upoad script
<?php // display file upload form
2
if (!isset($_POST['submit'])) { ?>
3
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
4
5
<input type="hidden" name="MAX_FILE_SIZE" value="8000000" /> Select file:
6
7
<input type="file" name="data" />
8
9
<input type="submit" name="submit" value="Upload File" /></form>
10
11
<?php
12
} else {
13
// check uploaded file size
14
if ($_FILES['data']['size'] == 0) {
15
die("ERROR: Zero byte file upload");
16
}
17
// check if file type is allowed (optional)
18
$allowedFileTypes = array("image/gif", "image/jpeg", "image/pjpeg");
19
if (!in_array($_FILES['data']['type'], $allowedFileTypes)) {
20
die("ERROR: File type not permitted");
21
} // check if this is a valid upload
22
if (!is_uploaded_file($_FILES['data']['tmp_name'])) {
23
die("ERROR: Not a valid file upload"); } // set the name of the target directory
24
$uploadDir = "./uploads/"; // copy the uploaded file to the directory
25
move_uploaded_file($_FILES['data']['tmp_name'], $uploadDir . $_FILES['data']['name']) or die("Cannot copy uploaded file"); // display success message
26
echo "File successfully uploaded to " . $uploadDir .$_FILES['data']['name']; } ?>
please can any one help me with code to download the files that have been uploaded.
this is my upoad script
<?php // display file upload form
2
if (!isset($_POST['submit'])) { ?>
3
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
4
5
<input type="hidden" name="MAX_FILE_SIZE" value="8000000" /> Select file:
6
7
<input type="file" name="data" />
8
9
<input type="submit" name="submit" value="Upload File" /></form>
10
11
<?php
12
} else {
13
// check uploaded file size
14
if ($_FILES['data']['size'] == 0) {
15
die("ERROR: Zero byte file upload");
16
}
17
// check if file type is allowed (optional)
18
$allowedFileTypes = array("image/gif", "image/jpeg", "image/pjpeg");
19
if (!in_array($_FILES['data']['type'], $allowedFileTypes)) {
20
die("ERROR: File type not permitted");
21
} // check if this is a valid upload
22
if (!is_uploaded_file($_FILES['data']['tmp_name'])) {
23
die("ERROR: Not a valid file upload"); } // set the name of the target directory
24
$uploadDir = "./uploads/"; // copy the uploaded file to the directory
25
move_uploaded_file($_FILES['data']['tmp_name'], $uploadDir . $_FILES['data']['name']) or die("Cannot copy uploaded file"); // display success message
26
echo "File successfully uploaded to " . $uploadDir .$_FILES['data']['name']; } ?>
please can any one help me with code to download the files that have been uploaded.
- reddys
Next Topics on Trending Feed
-
1