我遇到了这段代码的问题。我已将文件路径设置为'上传/'但它没有成功。我没有收到成功消息或失败的消息。我是PHP的新手,所以可能会犯一个非常简单的错误。谢谢。
<?php
$name = $_FILES['video']['name'];
$size = $_FILES['video']['size'];
$type = $_FILES['video']['type'];
$tmp_name = $_FILES['video']['tmp_name'];
if(isset($name)){
if(!empty($name)){
$location = 'uploads/';
if (move_uploaded_file($tmp_name, $location.$name)){
echo 'Success!';
}
}
}else{
echo 'Failed';
}
?>
答案 0 :(得分:0)
试试这个:
$name = $_FILES['video']['name'];
$video_tmp = $_FILES['video']['tmp_name'];
if(isset($name)){
if(!empty($name)){
move_uploaded_file($video_tmp,”video/my_videos/$name”);//change video/my_videos to the correct path where you'll like to store them
echo "success";
}
}else{
echo 'Failed';
}