PHP错误文件未上传此API代码

时间:2019-05-21 08:10:29

标签: php ubuntu-16.04

此api代码在php中,服务器在digitalocen和ubuntu 16.04中。 我们正在尝试上传文件,但是每次显示错误参数都丢失。 我们正在尝试更改文件夹权限777,但没有上传任何钢文件。相同的代码可以工作2天,但现在代码不起作用。

 <?php
include('conn.php');
include('function.php');

$user_id = $_POST['user_id'];
$dute_user_id = $_POST['dute_user_id'];
$music_id = $_POST['music_id'];
$music = $_FILES['music']['name'];
$hashtags = $_POST['hashtags'];
$video = $_FILES['video']['name'];
$gif = $_FILES['gif']['name'];

$microtime = round(microtime(true) * 1000);

validate_user($con, $user_id);

if($user_id=="" || $video=="" || $gif=="" || ($music_id=="" && $music=="")){
    $res['status'] = 0;
    $res['msg'] = "param missing";
    echo json_encode($res);
    die;
}
else{
    $user_data = mysqli_fetch_assoc(mysqli_query($con, "SELECT * FROM `user` WHERE `user_id`='".$user_id."'"));
    if($music_id=="" && $music!=""){
        $music = basename($_FILES["music"]["name"]);
        $fileType = strtolower(pathinfo($music,PATHINFO_EXTENSION));
        $music_file = "music/" . $microtime .".". $fileType;
        move_uploaded_file($_FILES["music"]["tmp_name"], $music_file);
        $title = "original - " . $user_data['user_name'] . rand(1111,9999);

        mysqli_query($con, "INSERT INTO `music` (`title`, `user_id`, `m_link`, `time`) VALUES ('".$title."', '".$user_id."', '".$music_file."', '".$microtime."')");
        $music_id = mysqli_insert_id($con);

        mysqli_query($con, "INSERT INTO `m_category` (`music_id`, `category_id`) VALUES ('".$music_id."', '1')");
    }

    if($video!=""){
        $video = basename($_FILES["video"]["name"]);
        $fileType = strtolower(pathinfo($video,PATHINFO_EXTENSION));
        $video_file = "video/" . $microtime .".". $fileType;
        move_uploaded_file($_FILES["video"]["tmp_name"], $video_file);
    }

    if($gif!=""){
        $gif = basename($_FILES["gif"]["name"]);
        $fileType = strtolower(pathinfo($gif,PATHINFO_EXTENSION));
        $gif_file = "gif/" . $microtime .".". $fileType;
        move_uploaded_file($_FILES["gif"]["tmp_name"], $gif_file);
    }

    mysqli_query($con, "INSERT INTO `post`(`music_id`, `v_url`, `user_id`, `dute_user_id`, `gif_url`, `time`) VALUES ('".$music_id."', '".$video_file."', '".$user_id."', '".$dute_user_id."', '".$gif_file."', '".$microtime."')");

    $post_id = mysqli_insert_id($con);

    if($dute_user_id!=""){
        mysqli_query($con, "INSERT INTO `post_hashtag`(`post`, `hashtag`) VALUES ('".$post_id."','duet')");
    }

    if($hashtags!=""){
        $hashtag = explode("#", $hashtags);

        for($i=0; $i < count($hashtag); $i++) {
            mysqli_query($con, "INSERT INTO `post_hashtag`(`post`, `hashtag`) VALUES ('".$post_id."','".$hashtag[$i]."')");
        }
    }   

    $res['status'] = 1;
    $res['msg'] = "Post Uploaded Successfully";
    echo json_encode($res);
    die;
}
?>

结果

{"status":0,"msg":"param missing"}

这是邮递员错误图片

enter image description here

0 个答案:

没有答案