图像上传与php错误?

图像上传与php错误?,php,Php,我只是想在php中创建一个简单的图像上传功能,但由于某些原因,它不会使用move\u uploaded\u file()移动图像。 我正在通过XAMPP工作,如果这很重要的话。 我也尝试过设置upload\u tmp\u dir (我知道缺乏准备好的陈述) action.php: $target_directory = "/Applications/XAMPP/xamppfiles/htdocs/uploads/"; $filename = $_POST['fileLocation']; $te

我只是想在php中创建一个简单的图像上传功能,但由于某些原因,它不会使用
move\u uploaded\u file()
移动图像。 我正在通过XAMPP工作,如果这很重要的话。 我也尝试过设置
upload\u tmp\u dir

(我知道缺乏准备好的陈述)

action.php:

$target_directory = "/Applications/XAMPP/xamppfiles/htdocs/uploads/";
$filename = $_POST['fileLocation'];
$temp_filename = $_FILES["file"]["tmp_name"];
$size = $_FILES["file"]["size"];

    // Produce a unique filename
$randomNumber = time();
$filetype = substr($filename, strrpos($filename, '.'));
$target_file = $target_directory . $randomNumber . $filetype;
$local_path = "/Applications/XAMPP/xamppfiles/htdocs/uploads/" . $randomNumber . $filetype;

header('Content-type: text/html; charset=utf-8');
if(!move_uploaded_file($temp_filename, $target_file))
        header( 'localhost/index.php', 301 );

// = = = = Add to database = = = =
$conn = mysql_connect("localhost", "root", "") or die(mysql_error());
$db = mysql_select_db("gps");

// Collect data from form
$imagetext = $_POST["imagetext"];
$locationstring = $_POST["locationstring"];


$query = "INSERT INTO gps (imagetext, file, locationstring) VALUES ('$imagetext', '$local_path','$locationstring')";
mysql_query($query);
mysql_close();
        header( 'localhost/index.php', 301 );
错误:

Warning: move_uploaded_file(/uploads/images/1495626347.psd): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/action.php on line 20

Warning: move_uploaded_file(): Unable to move '/Applications/XAMPP/xamppfiles/temp/phpYsJkjq' to '/uploads/images/1495626347.psd' in /Applications/XAMPP/xamppfiles/htdocs/action.php on line 20

第20行是:
如果(!move_uploaded_file($temp_filename,$target_file))

检查您的路径和权限html是未知的,因此其中可能有不正确的内容,所以请检查是否也使用了大量的绝对路径;-)@u_Mulder尝试将文件保存到任何其他位置,就像任何其他驱动器一样,并提供完整路径