我想使用PHP将用户提供的图片上传到像imgur这样的网站,但不是imgur,因为它要我使用一些我现在无法卸载的奇怪的邮递员。我不知道怎么做,花了一个小时搜索。我知道stackoverflow使用imgur,但我想避免它。
答案 0 :(得分:0)
file_uploads = On
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = 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;
}
}
?>