PHP image upload function, save in a dir and then return save image url

前端 未结 5 401
被撕碎了的回忆
被撕碎了的回忆 2021-01-03 12:55

I am trying to upload an image to server using PHP and the save inside a dir, and then returning the image url.

HTML:



        
5条回答
  •  生来不讨喜
    2021-01-03 13:59

    Here's a simple one.

    HTML form to upload image

    Send this file:

    Your PHP file that does the Upload

    ";
    
    if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
      echo "File is valid, and was successfully uploaded.\n";
    } else {
       echo "Upload failed";
    }
    
    echo "

    "; echo '
    ';
    echo 'Here is some more debugging info:';
    print_r($_FILES);
    print "
    "; ?>

    Source

提交回复
热议问题