我正在研究需要PHP来创建文件和文件夹。我正在使用fopen
来创建文件。但是,它似乎并不奏效。当我编写代码时,我在Windows上使用WAMP,并且一切正常,但是当我将该站点移动到Ubuntu服务器时,该脚本根本无法工作。fopen无法创建文件
这是我使用的文件创建和子平
mkdir($sessionid, 777);
// create the server.properties
$server_config = fopen("$sessionid/server.properties",'a');
$config = "test";
fwrite($server_config,$config);
fclose($server_config);
// create the run.sh/bat
$server_script = fopen("$sessionid/RUN.$platform", 'a');
fwrite($server_script,$script);
fclose($server_script);
// zip them all together
$zip = new ZipArchive();
$ow = 1;
$file= "$sessionid/RFSLABSserver.zip";
if($zip->open($file,$ow?ZIPARCHIVE::OVERWRITE:ZIPARCHIVE::CREATE)===TRUE)
{
// Add the files to the .zip file
$zip->addFile("/$sessionid/server.properties", "server.properties");
$zip->addFIle("/$sessionid/RUN.$platform", "Start.$platform");
// file source as file name
$zip->close();
}
什么脚本所做的是创建一个文件夹与一个随机数的会话ID和该文件夹内创建代码2个文件并压缩它们。请注意,文件夹已创建,但不包含
您应该永远不要为简单的Web应用程序设置777权限。 – JakeGould