文件上传后执行的代码
<?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!";
}
?>
把临时目录里你上传的文件,移动到你的uploads目录下
$target_path = "uploads/";//设置你的上传文件目录
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); //获取上传的文件名
//下面的就是移动文件,把$_FILES里的$_FILES['uploadedfile']['tmp_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!";
}追问
$target_path = "uploads/";//设置你的上传文件目录
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); //获取上传的文件名
//下面的就是移动文件,把$_FILES里的$_FILES['uploadedfile']['tmp_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!";
}追问
这个可以用别的语言重写吗。
温馨提示:答案为网友推荐,仅供参考
第1个回答 2014-05-21
将上传的文件移动到新位置,如果移动成功输出文件已经上传,否则输出上传失败追问
这个可以用别的语言来写吗,因为没有接触过php所以电脑上没有php的运行环境
第2个回答 2014-05-21
这个是PHP后端用来接收上传文件的代码,js是前端,无法实现。追问
那能解释一下吗,因为没有接触过php没看懂这个是什么意思
太谢谢了