-5

我正在尝试将 XML 文件上传到服务器,该文件名为data.xml. 每次访问数据时,数据总是会被覆盖。

我的疑问是如何将文件名设置为带有.xml扩展名的固定名称作为扩展名过滤器?我想将文件放在与upload.php.

这是我到目前为止所尝试的:

<?php

$target_path = "uploads/";

$target_path = $target_path . basename($_FILES['uploadedfile']['name']);

if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ", basename($_FILES['uploadedfile']['name']), " has been uploaded";
} else {
    echo "There was an error uploading the file, please try again!";
}
4

1 回答 1

0

你有没有尝试过:

<?
$target_path = "uploads/";

$target_path = $target_path . 'data.xml'; 

 if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
" has been uploaded";
 } else{
 echo "There was an error uploading the file, please try again!";
 }
?>
于 2013-02-19T20:17:31.270 回答