Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 输入URL时未显示图像_Php_Html - Fatal编程技术网

Php 输入URL时未显示图像

Php 输入URL时未显示图像,php,html,Php,Html,那么,您知道如何使用InfinityFree PHP托管创建图像上传系统吗? 我做了一个,但有个问题。当我获得图像并粘贴链接到Discord Chat中时,它不会显示为图像,而是显示链接。我看到有人使用了InfinityFree并粘贴了链接,但它起作用了!我不知道该怎么做。请帮忙 Coding: HTML CODE <!DOCTYPE html> <html> <body> &l

那么,您知道如何使用InfinityFree PHP托管创建图像上传系统吗? 我做了一个,但有个问题。当我获得图像并粘贴链接到Discord Chat中时,它不会显示为图像,而是显示链接。我看到有人使用了InfinityFree并粘贴了链接,但它起作用了!我不知道该怎么做。请帮忙

Coding: HTML CODE
        <!DOCTYPE html>
        <html>
        <body>
        
        <form action="upload.php" method="post" enctype="multipart/form-data">
          Select image to upload:
          <input type="file" name="fileToUpload" id="fileToUpload">
          <input type="submit" value="Upload Image" name="submit">
        </form>
        
        </body>
        </html>
    
    PHP code: 
    
        <?php
        $target_dir = "uploads/";
        $target_file = $target_dir . uniqid("", false));
        $uploadOk = 1;
        $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
        
        // Check if image file is a actual image or fake image
        if(isset($_POST["submit"])) {
          $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
          if($check !== false) {
            echo "File is an image - " . $check["mime"] . ".";
            $uploadOk = 1;
          } else {
            echo "File is not an image.";
            $uploadOk = 0;
          }
        
        // Check file size
        if ($_FILES["fileToUpload"]["size"] > 500000) {
          echo "Sorry, your file is too large.";
          $uploadOk = 0;
        }
        
        // Allow certain file formats
        if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
        && $imageFileType != "gif" ) {
          echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
          $uploadOk = 0;
        }
        
        // Check if $uploadOk is set to 0 by an error
        if ($uploadOk == 0) {
          echo "Sorry, your file was not uploaded.";
        // if everything is ok, try to upload file
        } else {
          if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
            echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded.";
          } else {
            echo "Sorry, there was an error uploading your file.";
          }
        }
        ?>
    
    Anyone know how to help?
编码:HTML代码
选择要上载的图像:
PHP代码:

如果你上传了一张图片,你能通过URL在浏览器中打开/显示它吗?你似乎没有给上传的文件任何文件扩展名?请尝试向文件名添加适当的文件扩展名,然后给我们一个您已上载的URL示例。wdym我上载的URL示例?