我有一个简单的PHP,可以将文件保存到特定文件夹。我已经在777中更改了权限,但是我遇到了错误:
EnvDTE.TextSelection ts = DTE.ActiveWindow.Selection as EnvDTE.TextSelection;
if (ts == null)
return;
EnvDTE.CodeFunction func = ts.ActivePoint.CodeElement[vsCMElement.vsCMElementFunction]
as EnvDTE.CodeFunction;
if (func != null)
System.Windows.MessageBox.Show(func.FullName);
如何解决这些问题?
PHP
Warning: file_put_contents(/var/www/html/foldername/): failed to open stream: Is a directory on line 22
Warning: chmod(): Operation not permitted on line 23
答案 0 :(得分:0)
当存在文件上载时,您应该使用$ _FILE获取数据,而不是使用$ _POST。尝试更改您的代码。
答案 1 :(得分:0)
我认为您的代码中很少需要进行更正。首先请在您的三元运算符中添加默认文件名,而不是file_put_content
使用fopen
和'r+'
,请检查url以获取更多选项,并在创建之前文件需要检查目录是否存在且可写。希望这会对你有所帮助。
答案 2 :(得分:0)
试试这个,
$file_name = '';
$file_binary = '';
$folder = "foldername";
$file_name = isset($_POST['file_name']) ? $_POST['file_name'] : '';
$file_binary = isset($_POST['file']) ? $_POST['file'] : '';
//to create directory:
$folderPath = "/var/www/html/foldername";
is_dir($folderPath) || @mkdir($folderPath) || die("Can't Create folder");
$file_directory = "/var/www/html/foldername/".$file_name;
file_put_contents($file_directory,str_replace("\\","",$file_binary));
chmod($file_directory,0777);