I am trying to upload a file in php,but it gives me error msg please Help me?
My Code is like below:-
i have one php file named upload.php and i have another html file named upload.html and inside html i am calling php file
upload.php:-
[code=php]
<?php
echo 'Name: '.$_FILES['userfile']['name'];
echo '<br />';
echo 'File type: '.$_FILES['userfile']['type'];
echo '<br />';
echo 'File size: '.$_FILES['userfile']['size'];
echo '<br />';
echo 'File temporary name: '.$_FILES['userfile']['tmp_name'];
echo '<br />';
echo 'File error: '.$_FILES['userfile']['error'];
echo '<br />';
if($_FILES['userfile']['size'] > 10000)
{
echo '<b>File Size too big.</b>';
}
elseif((move_up loaded_file($_F ILES['userfile']['tmp_name'], "C:\Program Files\EasyPHP 2.0b1\www\File Handling")))
{
echo '<b>Your file has been uploaded successfully.</b><br /><a href="files/'.$_FILES['userfile']['name'].'">Check it out here</a>';
}
else echo '<i>Error while uploading!</i>';
?>
[/code]
upload.html:-
[code=html]
<html>
<head>
<title>File Upload</title>
</head>
<body>
<h1>Upload a file</h1>
<form enctype="multip art/form-data" action="upload. php" method="post">
<p>
<input type="hidden" name="max_file_ size" value="10000">
Choose a file: <input name="userfile" type="file" >
</p>
<p>
<input type="submit" value="Send File"></p>
</form>
</body>
</html>
[/code]
When i am running it gives me the following message:-
My Code is like below:-
i have one php file named upload.php and i have another html file named upload.html and inside html i am calling php file
upload.php:-
[code=php]
<?php
echo 'Name: '.$_FILES['userfile']['name'];
echo '<br />';
echo 'File type: '.$_FILES['userfile']['type'];
echo '<br />';
echo 'File size: '.$_FILES['userfile']['size'];
echo '<br />';
echo 'File temporary name: '.$_FILES['userfile']['tmp_name'];
echo '<br />';
echo 'File error: '.$_FILES['userfile']['error'];
echo '<br />';
if($_FILES['userfile']['size'] > 10000)
{
echo '<b>File Size too big.</b>';
}
elseif((move_up loaded_file($_F ILES['userfile']['tmp_name'], "C:\Program Files\EasyPHP 2.0b1\www\File Handling")))
{
echo '<b>Your file has been uploaded successfully.</b><br /><a href="files/'.$_FILES['userfile']['name'].'">Check it out here</a>';
}
else echo '<i>Error while uploading!</i>';
?>
[/code]
upload.html:-
[code=html]
<html>
<head>
<title>File Upload</title>
</head>
<body>
<h1>Upload a file</h1>
<form enctype="multip art/form-data" action="upload. php" method="post">
<p>
<input type="hidden" name="max_file_ size" value="10000">
Choose a file: <input name="userfile" type="file" >
</p>
<p>
<input type="submit" value="Send File"></p>
</form>
</body>
</html>
[/code]
When i am running it gives me the following message:-
Code:
Name: testfile.txt File type: text/plain File size: 42 File temporary name: C:/Program Files/EasyPHP 2.0b1\tmp\php1AD.tmp File error: 0 Warning: move_uploaded_file(C:\Program Files\EasyPHP 2.0b1\www\File Handling) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Program Files\EasyPHP 2.0b1\www\File Handling\upload.php on line 21 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:/Program Files/EasyPHP 2.0b1\tmp\php1AD.tmp' to 'C:\Program Files\EasyPHP 2.0b1\www\File Handling' in C:\Program Files\EasyPHP 2.0b1\www\File Handling\upload.php on line 21 Error while uploading!
Comment