php upload image files on IIS
I haven't been able to upload files via forms on IIS. I am wondering if it is the settings. File uploads are set to "on" in my php.ini file and here is my code
<?php
<form name=\"form1\" method=\"post\" action=\"upload.php\" enctype=\"multipart/form-data\">
<input type=\"file\" name=\"userfile\">
<br>
<input type=\"submit\" name=\"Submit\" value=\"Upload File\">
</form>
?>
<?php
if($_FILES['userfile']!=\" \")
{
echo \"hello\";
}
if($_FILES['userfile']['error']>0)
{
echo \"problem\";
}
$upfile=\"/img/alt/\";
$uploaddir = 'img/alt/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo \"File is valid, and was successfully uploaded.\n\";
} else {
echo \"Possible file upload attack!\n\";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print \"</pre>\";
?>
Any suggestions?
JeevesBond posted this at 00:29 — 22nd August 2007.
He has: 3,956 posts
Joined: Jun 2002
Am not trying to be rude here, but don't think many people will be able to answer this as we're all running PHP with Apache (I'd be happy for someone to prove me wrong in this!)
Will do what I can though: usually the problem is that the script is trying to upload somewhere that either doesn't exist or where the web server doesn't have permission to upload to. What errors do you get back? Do you get anything back from print_r($_FILES)?
a Padded Cell our articles site!
L3ZL1E posted this at 13:56 — 22nd August 2007.
They have: 32 posts
Joined: Feb 2007
No offense taken...I know I am crazy for not running it on Apache.
this is the output
Possible file upload attack!
Here is some more debugging info:Array
(
[userfile] => Array
(
[name] => 206.jpg
[type] => image/jpeg
[tmp_name] => C:\PHP\upload\php75F8.tmp
[error] => 0
[size] => 1528
)
)
IanD posted this at 19:02 — 7th September 2007.
They have: 222 posts
Joined: Sep 1999
I would think $uploaddir would have to be the absolute path on the filesystem, so it'd be more like $_SERVER['DOCUMENT_ROOT'] . '/img/alt/'
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.