Hello,
The code i used for uploading is....
upload.html
- Code: Select all
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form enctype="multipart/form-data" action="uploader.php" method="POST">
Choose a file to upload: <input name="file" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>
uploader.php
- Code: Select all
<?php
$name = htmlspecialchars($_FILES["file"]["name"]);
$type = htmlspecialchars($_FILES["file"]["type"]);
$size = htmlspecialchars($_FILES["file"]["size"]);
$path = htmlspecialchars($_FILES["file"]["tmp_name"]);
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
} else {
echo "Upload: " . $name . "<br />";
echo "Type: " . $type . "<br />";
echo "Size: " .$size. " Kb<br />";
echo "Temp file: " . $path. "<br />";
if (file_exists("upload/" . $name)) {
echo $name. " already exists. ";
} else {
move_uploaded_file($path, "upload/" . $name);
echo "Stored in: " . "upload/" . $name."<br /><br />";
}
}
?>
To upload file greater than 2MB , i used the .htaccess in the root directory of the server...
.htaccess
- Code: Select all
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 0
php_value max_input_time 0
But it still not working. If i try to upload file > 2MB, it returns error code 1.
Please help me.
Thanks
Nishith