PHP - 复制导致HTTP错误500

时间:2018-01-08 07:23:49

标签: php centos

PHP on execute导致HTTP错误500.我在driver_license.exe上有chmod -R 777。

enter image description here

<?php
$agent= $_GET['agentid'];
$userid = $_GET['userid'];

$file = "/home/www/file/driver_license.exe";
$path = "/home/www/file/";
"
$newfile ="driver_license_userid_1.exe";

$file_to_save = $path . $newfile;
if (!copy($file, $file_to_save)) {
    echo "FAILED";
}
else {
  echo "<a href=https://download.example.com/{$newfile}>DOWNLOAD & INSTALL</a>";
}

1 个答案:

答案 0 :(得分:3)

1.在"之后你还有$path = "/home/www/file/";。删除它。

2.您忘记在href周围添加引号。添加

所以代码必须是: -

<?php
$agent= $_GET['agentid'];
$userid = $_GET['userid'];

$file = "/home/www/file/driver_license.exe";
$path = "/home/www/file/";
 //" need to remove or comment
$newfile ="driver_license_userid_1.exe";

$file_to_save = $path . $newfile;
if (!copy($file, $file_to_save)) {
    echo "FAILED";
}
else {
  echo "<a href='https://download.example.com/{$newfile}'>DOWNLOAD & INSTALL</a>"; // ' added around href
}

重要提示: - 文件夹需要获得访问权限(授予077个文件夹home,www and file权限)