Forum Moderators: coopster

Message Too Old, No Replies

php file upload.

server problem?

         

ayushchd

4:03 am on May 9, 2007 (gmt 0)

10+ Year Member



<?php
if (($_FILES["file"]["type"] == "application/vnd.ms-excel"))
{
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("/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"/" . $_FILES["file"]["name"]);
echo "Stored in: " . "/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>

This code works fine on localhost but not on the server...cud it be a server issue..or is there some other thing that we need to do when uploading on the server?

phparion

5:29 am on May 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



chmod could be the problem.. chmod your folder in which you want to store excel files so that is writable.