Is Windows Server Support File Uploads? [modified]
-
Hi All Now Iam In A Problem Is it possible to upload file to a windows server? i used this code for uploading file i got this code from w3schools.com
Filename:
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";if (file\_exists("upload/" . $\_FILES\["file"\]\["name"\])) { echo $\_FILES\["file"\]\["name"\] . " already exists. "; } else { move\_uploaded\_file($\_FILES\["file"\]\["tmp\_name"\], "upload/" . $\_FILES\["file"\]\["name"\]); echo "Stored in: " . "upload/" . $\_FILES\["file"\]\["name"\]; } }
}
else
{
echo "Invalid file";
}This Script is Working Good On My Local wamp server and also working fine in my linux server i checked phpinfo() of my windows server fileupload is on and max_upload size is 32 mb Thease Are My Server informations OS/Hosting Type: Windows / 4GH Web Hosting Hosting Configuration: .Net Runtime Version: ASP.Net 2.0/3.0/3.5 PHP Version: PHP 5.3 IIS Version: IIS 7.0 Please Help Me To Do This Arunkumar.T :((
modified on Thursday, August 4, 2011 7:02 AM
-
Hi All Now Iam In A Problem Is it possible to upload file to a windows server? i used this code for uploading file i got this code from w3schools.com
Filename:
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";if (file\_exists("upload/" . $\_FILES\["file"\]\["name"\])) { echo $\_FILES\["file"\]\["name"\] . " already exists. "; } else { move\_uploaded\_file($\_FILES\["file"\]\["tmp\_name"\], "upload/" . $\_FILES\["file"\]\["name"\]); echo "Stored in: " . "upload/" . $\_FILES\["file"\]\["name"\]; } }
}
else
{
echo "Invalid file";
}This Script is Working Good On My Local wamp server and also working fine in my linux server i checked phpinfo() of my windows server fileupload is on and max_upload size is 32 mb Thease Are My Server informations OS/Hosting Type: Windows / 4GH Web Hosting Hosting Configuration: .Net Runtime Version: ASP.Net 2.0/3.0/3.5 PHP Version: PHP 5.3 IIS Version: IIS 7.0 Please Help Me To Do This Arunkumar.T :((
modified on Thursday, August 4, 2011 7:02 AM
use this to make sure the file is posting the data to the server.
";
print_r($_POST);
print_r($_FILES);
echo ""; ?> place that at the top of the script you are posting to (upload_file.php) and run it. If your post and files are getting to the server then look at your file permissions of the target directory and of the upload_file.php and make sure they are permitted to do what you want them to do.
Chris J www.redash.org
-
use this to make sure the file is posting the data to the server.
";
print_r($_POST);
print_r($_FILES);
echo ""; ?> place that at the top of the script you are posting to (upload_file.php) and run it. If your post and files are getting to the server then look at your file permissions of the target directory and of the upload_file.php and make sure they are permitted to do what you want them to do.
Chris J www.redash.org
Thank you For Helping me cjoki I Done What you Said Igot this message i got message like this
Array
(
[submit] => Submit
)
Array
(
[file] => Array
(
[name] => Water lilies.jpg
[type] => image/jpeg
[tmp_name] => D:\Temp\php\php9B61.tmp
[error] => 0
[size] => 83794
)
)I Thing It Seems Ok But The File Uploading Is Failed Can you Tell Me Why This Happen ? Please Help Me? Arunkumar.T :((
-
Thank you For Helping me cjoki I Done What you Said Igot this message i got message like this
Array
(
[submit] => Submit
)
Array
(
[file] => Array
(
[name] => Water lilies.jpg
[type] => image/jpeg
[tmp_name] => D:\Temp\php\php9B61.tmp
[error] => 0
[size] => 83794
)
)I Thing It Seems Ok But The File Uploading Is Failed Can you Tell Me Why This Happen ? Please Help Me? Arunkumar.T :((
Your file upload did not fail...but looking at your echoed $_FILES data and your code snip the issue looks to be in this area...can you see it?
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))compare this to your last post.
Chris J www.redash.org
-
Your file upload did not fail...but looking at your echoed $_FILES data and your code snip the issue looks to be in this area...can you see it?
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))compare this to your last post.
Chris J www.redash.org
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))Yes I Removed These Statements From My Code Now Uploading is working fine but how can i validate file type and file errors ? is there any other way to do this? Thankyou Arunkumar.T :((