Telegraph-Image icon indicating copy to clipboard operation
Telegraph-Image copied to clipboard

无法上传图片 2024年9月6日18点28分

Open aixindao opened this issue 1 year ago • 12 comments

Snipaste_2024-09-06_18-28-05

aixindao avatar Sep 06 '24 10:09 aixindao

me too

Unarmored7 avatar Sep 06 '24 11:09 Unarmored7

可能tg封了

sucooer avatar Sep 06 '24 12:09 sucooer

+1 Snipaste_2024-09-06_22-04-49

mundane799699 avatar Sep 06 '24 14:09 mundane799699

把接口修一修就可以继续用了。

可以自己部署一个兼容程序:

<?php

$targetDir = "file/";
$targetFile = $targetDir . basename($_FILES["file"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION));

if (isset($_FILES['file'])) {
    $check = getimagesize($_FILES["file"]["tmp_name"]);
    if ($check !== false) {
        //echo "Log: File-mine" . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        //echo "Log: mine err";
        $uploadOk = 0;
    }
}

if (file_exists($targetFile)) {
    //echo "Log: file exists.";
    $uploadOk = 0;
}

if ($_FILES["file"]["size"] > 5000000) { // 限制为5M
    //echo "Log: file too big.";
    $uploadOk = 0;
}

if (!in_array($imageFileType, ["jpg", "png", "jpeg", "gif"])) {
    echo "Log:Only upload: JPG, JPEG, PNG & GIF file.";
    $uploadOk = 0;
}

if ($uploadOk == 0) {
    echo '{"msg":"upload fail."}';
} else {
    if (move_uploaded_file($_FILES["file"]["tmp_name"], $targetFile)) {
        $responsex = [["src" => $targetFile]];
        echo json_encode($responsex);
    } else {
        echo '{"msg":"500 ERROR."}';
    }
}
?>

把上面程序任意丢在php运行环境中,配置好伪静态 /upload - > /upload.php,配置好同目录文件夹 ./file/。就能用了,

要自用的话,可以配合IP白名单+反代鉴权。

程序自测,有bug自修。改接口地址就能用了

oplxc avatar Sep 06 '24 15:09 oplxc

我也是

chai3721 avatar Sep 06 '24 15:09 chai3721

+1

buganmao avatar Sep 07 '24 00:09 buganmao

请查看issue:#180 Telegram官方取消了上传接口,目前正在寻找替代的上传方案

cf-pages avatar Sep 07 '24 02:09 cf-pages

把接口修一修就可以继续用了。

可以自己部署一个兼容程序:

<?php

$targetDir = "file/";
$targetFile = $targetDir . basename($_FILES["file"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION));

if (isset($_FILES['file'])) {
    $check = getimagesize($_FILES["file"]["tmp_name"]);
    if ($check !== false) {
        //echo "Log: File-mine" . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        //echo "Log: mine err";
        $uploadOk = 0;
    }
}

if (file_exists($targetFile)) {
    //echo "Log: file exists.";
    $uploadOk = 0;
}

if ($_FILES["file"]["size"] > 5000000) { // 限制为5M
    //echo "Log: file too big.";
    $uploadOk = 0;
}

if (!in_array($imageFileType, ["jpg", "png", "jpeg", "gif"])) {
    echo "Log:Only upload: JPG, JPEG, PNG & GIF file.";
    $uploadOk = 0;
}

if ($uploadOk == 0) {
    echo '{"msg":"upload fail."}';
} else {
    if (move_uploaded_file($_FILES["file"]["tmp_name"], $targetFile)) {
        $responsex = [["src" => $targetFile]];
        echo json_encode($responsex);
    } else {
        echo '{"msg":"500 ERROR."}';
    }
}
?>

把上面程序任意丢在php运行环境中,配置好伪静态 /upload - > /upload.php,配置好同目录文件夹 ./file/。就能用了,

要自用的话,可以配合IP白名单+反代鉴权。

程序自测,有bug自修。改接口地址就能用了

就这么简单?

woshichenghaibo avatar Sep 08 '24 05:09 woshichenghaibo

How to deploy a compatible program of your own? Are there any reference examples? Do I still need to buy a server?

ilyton avatar Sep 09 '24 14:09 ilyton

How to deploy a compatible program of your own? Are there any reference examples? Do I still need to buy a server?

Any PHP environment can be deployed, including free php host, virtual php host, vps, etc.

oplxc avatar Sep 09 '24 15:09 oplxc

B站搜索“Telegraph图床(Unknown Error)完美兼容老版本”有解决视频

ohn-max avatar Sep 10 '24 08:09 ohn-max

B站搜索“Telegraph图床(Unknown Error)完美兼容老版本”有解决视频

确实不错,我试试

woshichenghaibo avatar Sep 12 '24 03:09 woshichenghaibo

图片

kenchikuliu avatar Sep 23 '24 12:09 kenchikuliu

匿名上传接口目前已经失效,目前项目最新代码是使用tg bot的方式上传,如有需要可以重新部署最新的代码

cf-pages avatar Dec 01 '24 16:12 cf-pages