Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aixindao opened this issue Sep 6, 2024 · 14 comments
Open

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

aixindao opened this issue Sep 6, 2024 · 14 comments

Comments

@aixindao
Copy link

aixindao commented Sep 6, 2024

Snipaste_2024-09-06_18-28-05

@yeslinyh
Copy link

yeslinyh commented Sep 6, 2024

me too

@sucooer
Copy link

sucooer commented Sep 6, 2024

可能tg封了

@mundane799699
Copy link

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

@oplxc
Copy link

oplxc commented Sep 6, 2024

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

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

<?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自修。改接口地址就能用了

@chai3721
Copy link

chai3721 commented Sep 6, 2024

我也是

@buganmao
Copy link

buganmao commented Sep 7, 2024

+1

@cf-pages
Copy link
Owner

cf-pages commented Sep 7, 2024

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

@woshichenghaibo
Copy link

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

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

<?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自修。改接口地址就能用了

就这么简单?

@ilyton
Copy link

ilyton commented Sep 9, 2024

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

@oplxc
Copy link

oplxc commented Sep 9, 2024

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.

@ohn-max
Copy link

ohn-max commented Sep 10, 2024

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

@woshichenghaibo
Copy link

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

确实不错,我试试

@kenchikuliu
Copy link

图片

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests