PHP Upload Script

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..

?View Code HTML4STRICT
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^^



Related Post:

Post a Comment

Your email is never published nor shared. You're allow to say what you want...

Blogroll Link Update
Warning: Unknown: write failed: Disk quota exceeded (122) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0