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

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条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题