我正在推出一个用Javascript
编写的小脚本,加载来自HTML
,text_script.html
的简单图片:
<body>
<img src="firstcar.gif" name="slide" width="100" height="56" />
<script>
Var image = [];
image[0]=new Image();
image[0].src="firstcar.gif“;
image[1]=new Image()
Image[1].src="secondcar.gif“;
var step=0;
function slideit(){
document.images.slide=image[step] ;
if (step<image.length) step++ else step=0;
setTimeout("slideit()",2500)
}
slideit();
</script>
</body>
这是我的Documents
文件夹的结构,其中包含脚本和3张图片,firstcar.git
,secondcar.gif
和thirdcar.gif
:
问题在于,当我在浏览器上执行代码时,它会返回此错误,“无法加载资源:服务器响应状态为403(禁止):
现在,我通过停止并重新启动服务器来检查:
sudo apachectl start
和sudo apachectl stop
我也仔细检查了文件的路径,但这些方法都没有效果。
我怀疑这是权限问题?如何解决?
答案 0 :(得分:1)
您使用的服务器是什么? Windows还是Linux?将权限更改为777.好吧,首先复制所有代码,这样您就可以返回了。假设Linux:
<?php
require_once '/PHPExcel/Classes/PHPExcel.php';
$file=$_POST['file']."_".date("ymd").".xlsx";
$table = "<table border='1'>".$_POST['table']."</table>";
$table = mb_convert_encoding($table, 'UTF-16LE', 'UTF-8');
$table = "\xFF\xFE" . $table;
// save $table inside temporary file that will be deleted later
$tmpfile = tempnam(sys_get_temp_dir(), 'html');
file_put_contents($tmpfile, $table);
// insert $table into $objPHPExcel's Active Sheet through $excelHTMLReader
$objPHPExcel = new PHPExcel();
$excelHTMLReader = PHPExcel_IOFactory::createReader('HTML');
$excelHTMLReader->loadIntoExisting($tmpfile, $objPHPExcel);
$objPHPExcel->getActiveSheet()->setTitle('biblio_uq9_excel'); // Change sheet's title if you want
unlink($tmpfile); // delete temporary file because it isn't needed anymore
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); // header for .xlxs file
header('Content-Disposition: attachment;filename='.$file); // specify the download file name
header('Cache-Control: max-age=0');
// Creates a writer to output the $objPHPExcel's content
$writer = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$writer->save('php://output');
exit;
?>
如果现在有效,那就是权限问题。您知道权利未正确设置。您可以复制原始文件夹并将权限更改为更安全的文件。
您可能需要为Apache设置读取权限,或将所有者更改为apache / httd进程。该用户的名称取决于您的服务器(Centos或Debian)和/或配置。
你要么使用Apache 2.2,在这种情况下你应该使用它:
cd /var/www/
sudo cp -rp htdocs backup
sudo chmod -R 777 htdocs
对于Apache 2.4,请使用:
<Directory /home/everett/webroot>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
所以关于<Directory [write_your_dir_here]>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
vs Require all granted
+ Order allow,deny
。