php代码部分看不懂,哪位大神可以帮解释一下,或者翻译成javascript
文件上传后执行的代码<?php$target_path="uploads/";$target_path=$target_path.basename($_FILES['up...
文件上传后执行的代码
<?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!";
}
?> 展开
<?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!";
}
?> 展开
3个回答
展开全部
把临时目录里你上传的文件,移动到你的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!";
}
追问
这个可以用别的语言重写吗。
展开全部
将上传的文件移动到新位置,如果移动成功输出文件已经上传,否则输出上传失败
追问
这个可以用别的语言来写吗,因为没有接触过php所以电脑上没有php的运行环境
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个是PHP后端用来接收上传文件的代码,js是前端,无法实现。
追问
那能解释一下吗,因为没有接触过php没看懂这个是什么意思
太谢谢了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询