dongzhazhuo0572 2016-09-25 14:15
浏览 182
已采纳

move_uploaded_file()正好需要2个参数,给出1

<?php

include("mysqlconnect.php");

function GetImageExtension($imagetype)
{
    if(empty($imagetype)) return false;

    switch($imagetype)
    {
        case 'image/bmp': return '.bmp';
        case 'image/gif': return '.gif';
        case 'image/jpeg': return '.jpg';
        case 'image/png': return '.png';
        default: return false;
     }
}



if (!empty($_FILES["uploadedimage"]["name"])) {

    $file_name=$_FILES["uploadedimage"]["name"];
    $temp_name=$_FILES["uploadedimage"]["tmp_name"];
    $imgtype=$_FILES["uploadedimage"]["type"];
    $ext= GetImageExtension($imgtype);
    $imagename=date("d-m-Y")."-".time().$ext;
    $target_path = "img/".$imagename;


    if(move_uploaded_file($temp_name)) {

        $query_upload="INSERT INTO test_image ('id' ,'image', 'image_path',     'submission_date') VALUES ('".$target_path."','".date("Y-m-d")."')";

        mysqli_query($query_upload) or die("error in $query_upload == ----> ".mysqli_error());  

    }else{

        exit("Error While uploading image on the server");
    } 

}

?>

Warning: move_uploaded_file() expects exactly 2 parameters, 1 given in /home/u957762221/public_html/saveimage.php on line 29

This code throws an Error when attempting to upload an image to the server

  • 写回答

3条回答 默认 最新

  • dsvjmc0907 2016-09-25 14:19
    关注

    move_uploaded_file(string $filename, string $destination)

    This function needs second parameter as destination (where to upload file). You just gave one parameter ($temp_name, which is file name). I see something similar to destination in your code, so try this instead:

    if(move_uploaded_file($temp_name, $target_path)) {
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)