开发者

Uploading a .xls file.

Here is my code:

<?php

require_once 'Excel/reader.php';

$data = new Spreadsheet_Excel_Reader();

move_uploaded_file($_FILES["file"]["tmp_name"],$_FILES["file"]["name"]);

$data->read($_FILES["file"]["name"]);


error_reporting(E_ALL ^ E_NOTICE);

echo "<table border='1'>";

echo "<tr><th>First Name</th><th>Middle Name</th><th>Last Name</th><th>Email ID</th></tr>";

for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++)
         {
echo "<tr>";


echo "<td>";

        echo $data->sheets[0]['cells'][$j+1][1];

echo "</td>";   

echo "<td>";    

        echo $data->sheets[0]['cells'][$j+1][2];

echo "</td>";


echo "<td>";


        echo $data->sheets[0]['cells'][$j+1][3];

echo "</td>";


echo "<td>";


        echo $data->sheets[0]['cells'][$j+1][4];

echo "</td>";

      开发者_开发技巧  //echo "<br>";


echo "</tr>";

        }


echo "</table>";


?>

This running fine on localhost, but when I try to run it on the server it shows:

Warning: move_uploaded_file(Book1.xls) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/wingsele/public_html/get.php on line 6

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpufQkcr' to 'Book1.xls' in /home/wingsele/public_html/get.php on line 6

The filename Book1.xls is not readable

What am I missing?


You need to set write permissions (chmod, probably using your FTP client) to the directory you're moving the uploaded file to.

Also, in this line:

move_uploaded_file($_FILES["file"]["tmp_name"],$_FILES["file"]["name"]);

you should specify a full path as the second parameter, e.g.

   move_uploaded_file($_FILES["file"]["tmp_name"],dirname(__FILE__)."/".$_FILES["file"]["name"]);

for the current directory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜