【发布时间】:2015-10-30 01:10:15
【问题描述】:
我在使用 fopen() 时遇到问题,当我尝试写入 unix 服务器上的文件时,该函数返回“无法打开流:没有这样的文件或目录”。 我的 PHP 应用程序在 Windows 上运行。
这是我使用 fopen 函数的代码:
$path = "/212.120.15.80/tmp/NMJ.pdf"; //Path to unix server
$url = $_FILES [$fileElementName] ['tmp_name'];
$newfname = $path;
$file = fopen ( $url, "rb" );
if ($file) {
$newf = fopen ( $newfname, "wb" );
$fopen = $newf;
if ($newf) {
while ( ! feof ( $file ) ) {
fwrite ( $newf, fread ( $file, 1024 * 8 ), 1024 * 8 );
}
}
}
if ($fopen === false) {
$return_fopen = 'Fichier non téléchargé';
} else {
$return_fopen = 'Le fichier a été déposé sur le serveur';
}
if ($file) {
fclose ( $file );
}
if ($newf) {
fclose ( $newf );
}
我对 tmp 目录具有写/读权限。
当我使用以下路径在 Windows 服务器上编写文件时,此代码有效:“\\Example/share”
【问题讨论】: