fputs 不在服务器上写入图像
fputs not writing image on the server
$data = file_get_contents($url);
$image = config_item('temp_upload').$image_name;
$file = fopen($image, 'w+');
//fputs($file, $data);
file_put_contents($file, $data, FILE_BINARY);
fclose($file);
fputs 和 file_put_contents 不工作。
我用 move_uploaded_file 创建了一个示例 php 上传文件,它适用于同一个上传文件夹。
fopen($image,'w+') actually create the image with 0 byte.
我试图将上传文件夹更改为 0777 nginx:nginx(nginx) apache:apache (php-fpm) 没有任何效果。相同的零字节图像。
禁用selinux。还是没用。我对此有任何错误。
已将 move_uploaded_file 替换为 file_put_contents 同样的问题。 php.ini 中有什么要更改的吗?搜索了一下,没有得到任何线索。
AFAIK file_put_contents 函数的第一个参数需要直接是 path/filename。您不需要 fopen 和 fclose 函数。
$data = file_get_contents($url);
$image = config_item('temp_upload').$image_name;
$file = fopen($image, 'w+');
//fputs($file, $data);
file_put_contents($file, $data, FILE_BINARY);
fclose($file);
fputs 和 file_put_contents 不工作。 我用 move_uploaded_file 创建了一个示例 php 上传文件,它适用于同一个上传文件夹。
fopen($image,'w+') actually create the image with 0 byte.
我试图将上传文件夹更改为 0777 nginx:nginx(nginx) apache:apache (php-fpm) 没有任何效果。相同的零字节图像。
禁用selinux。还是没用。我对此有任何错误。
已将 move_uploaded_file 替换为 file_put_contents 同样的问题。 php.ini 中有什么要更改的吗?搜索了一下,没有得到任何线索。
AFAIK file_put_contents 函数的第一个参数需要直接是 path/filename。您不需要 fopen 和 fclose 函数。