Re: Re: file upload faliure
| From: | Seung Hwan Kang | Date: | Mon, 21 Apr 2003 05:43:11 +0000 |
| Subject: | Re: Re: file upload faliure | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-19520@lists.php.net to get a copy of this message | ||
it strang! my code works fine on my machine.
win2k pro. + sp3
apache 2.0.45
openssl 0.9.6g (comes with php)
php 4.3.1
zend optimizer 2.1.0a
here is full codoes of my files.
upload.html
--------
<form enctype="multipart/form-data" action="upload.php" method="post">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>
-----------
upload.php
-----------
<?
echo $_FILES['userfile']['tmp_name'] . "<br />";
echo $_FILES['userfile']['name'] . "<br />";
echo $_FILES['userfile']['type'] . "<br />";
echo "<p>";
function fileupload()
{
if (is_uploaded_file($_FILES['userfile']['tmp_name']))
{
echo $PATH = $_SERVER['DOCUMENT_ROOT'] . "/test/";
// check whether a file exists or not
if (!file_exists($_FILES['userfile']['name']))
{
// echo "yes it exists";
// }
// check uploadable file types
echo $_FILES['userfile']['type'];
echo "<p>";
if ( $_FILES['userfile']['type'] == "application/pdf" ||
$_FILES['userfile']['type'] == "application/msword" ||
$_FILES['userfile']['type'] == "application/vnd.ms-excel" ||
$_FILES['userfile']['type'] == "application/msaccess" ||
$_FILES['userfile']['type'] == "application/vnd.ms-powerpoint" ||
$_FILES['userfile']['type'] == "application/x-zip-compressed" ||
$_FILES['userfile']['type'] == "application/postscript" ||
$_FILES['userfile']['type'] == "text/plain" )
{
copy($_FILES['userfile']['tmp_name'], $PATH . $_FILES['userfile']['name']);
}
else
{
echo "This type of file is NOT allowed to upload";
}
}
else
{
echo "Yes! the file already exist!";
}
}
else
{
echo "Possible file upload attack: filename " . $_FILES['userfile']['name'] . "<br>.";
}
}
?>
<?
fileupload();
?>
--------------
Vivek Kumar wrote:
dear S. H. Kang,Ok, here is my own codes. plz use it as areference.upload.html --------------------------- <html> ... <form enctype="multipart/form-data" action="upload.php" method="post"> Send this file: <input name="userfile" type="file"> <input type="submit" value="Send File"> </form> ... </html> ---------------------- <? // upload.php function fileupload() { if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {I have tried your code also but it gives me (with error_reporting(E_ALL) : """" Notice: Undefined index: userfile in C:\Program Files\Apache Group\Apache2\htdocs\php\upload.php on line 27 Notice: Undefined index: userfile in C:\Program Files\Apache Group\Apache2\htdocs\php\upload.php on line 35 Possible file upload attack: filename . """" To check my apache configuration i tried using a python cgi script to upload the file. It works fine, no problems at all with the python cgi. does php have some problem over SSL for file upload? as i previously mentioned my configuration is Apache 2.0.44 (win32) mod_ssl 2.0.44 OpenSSL 0.9.7a port 443 Php 4.3.1 Windows 2000 prof. ( service pack 3) THX, Vivek Kumar __________________________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo http://search.yahoo.com$PATH = $_SERVER['DOCUMENT_ROOT'] . "/tmp/"; echo $_FILES['userfile'['type']; copy($_FILES['userfile']['tmp_name'], $PATH . $_FILES['userfile']['name']);} else {echo "Possible file upload attack: filename " .$_FILES['userfile']['name'] . "<br>."; } } fileupload(); ?>