Php 从ios到指定服务器文件夹的HTTP POST上载

Php 从ios到指定服务器文件夹的HTTP POST上载,php,ios,file-upload,ftp,server-side,Php,Ios,File Upload,Ftp,Server Side,我想允许我的ios应用程序将html文件上传到ubuntu服务器的文件夹中 我正在从ios发送http post。 我只想上传到我服务器上的这个文件夹 这只是一个功能的原型,外部世界将无法使用它,所以我现在没有安全顾虑 <?php error_reporting(E_ALL); ini_set('display_errors', 1); $target_dir = "/var/www/html/"; $postVar = $_POST['data']; $target_file = $ta

我想允许我的ios应用程序将html文件上传到ubuntu服务器的文件夹中

我正在从ios发送http post。 我只想上传到我服务器上的这个文件夹

这只是一个功能的原型,外部世界将无法使用它,所以我现在没有安全顾虑

<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
$target_dir = "/var/www/html/";
$postVar = $_POST['data'];
$target_file = $target_dir . basename(“test.html");

$fp = fopen($target_file, "w") or die("Couldn't open $target_file for writing!");
fwrite($fp, $postVar) or die("Couldn't write values to file!"); 

fclose($fp); 
echo "Saved to $file successfully!";

header("Content-Disposition: attachment; filename=" . basename($target_file));
?>

看起来您使用的是相对路径,请尝试绝对路径。。。请注意前导“/”


如果这在原始代码中是正确的,请确保运行web服务的用户具有对/var/www/html/的写访问权限……我已更改了权限,使www数据具有写访问权限,这是想法吗?这是一个开始。。。并在php脚本的开头添加错误日志和错误报告(E_ALL);ini设置(“显示错误”,1);好的,最后我登录到webmin并记录执行权限,不确定是否需要执行。在脚本开始添加错误日志后,您是否看到任何错误?
$target_dir = "/var/www/html"