I create a simple script for upload file with PHP. First let’s make a page, for ex:upload_page.html
and copy this script..
1
2
3
4
5
6
7
8
9
10
11
| <html>
<head>
<title>Upload script</title>
</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
</body>
</html> |
Then create another page “upload.php” and add this php script..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| <?php
$filename = $_FILES['uploaded']['name'];
$filesize = $_FILES['uploaded']['size'];
$target = "upload/";//upload target
$target = $target . basename( $_FILES['uploaded']['name']) ;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ".$filename." -its size is ".$filesize."bytes has been uploaded!";
}
else
{
echo "Sorry, there was a problem uploading your file!";
}
?> |
Try to upload your file to specified folder^^
Sphere: Related Content Tags: PHP
|
 Loading ...
|
Leave a Comment