正在将文件保存到php [英] Saving file in php
本文介绍了正在将文件保存到php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个变量:$ Name =文件的名称。
现在我下载一个文件,并使用该名称及其扩展名存储在其中。我使用cURL。
I have a variable: $Name = "name of the file". Now I download a file and store in it with that name and its extension. I used cURL.
$Name = "name of the file"
$fp = fopen ('download/$Name.zip' , 'w+');
$ch = curl_init($downurl);
但这没有效果。它保存了一个名为$ Name.zip的文件
我想将其保存为下载文件夹中的file.zip的名称。
But this didn't work. It saved a file named $Name.zip I want it to be saved as "name of the file.zip" in download folder.
php。请帮帮我。感谢!
I am learning php. Please help me. Thanks!
推荐答案
在 fopen
p>
Use double quotes in the fopen
call:
$fp = fopen ("download/$Name.zip" , 'w+');
如果用单引号括住字符串,变量的插值不起作用,报价。您可以阅读关于维基百科上的变量插值的详情。
Interpolation of variables doesn't work if you surround the string in single quotes, it has to be double quotes. You can read more about variable interpolation on Wikipedia.
这篇关于正在将文件保存到php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文