나는 file_get_contents()
기능을 사용하여 $image
변수를 정의한 후이 경고를 받았는데 :변수가 값을 전달할 때 null 인 것처럼 처리되는 이유는 무엇입니까?
경고 : file_get_contents를() : 파일 이름은 내가 함께
$formname
에 값을 전달하더라도 빈
수 없습니다 이 메서드 호출 :
Image::uploadImage('postimg', "UPDATE dry_posts SET postimg = :postimg WHERE id = :postid", array(':postid' => $postid),array(':postimg' => $postimg));
$postimg
가있다 파일 변수. 파일이 존재하는지, 오류를 해결했는지는 검사를 시도했지만 아무 것도 실행되지 않았습니다. 내가 file_get_contents()
을 사용할 때마다 그것을 좋아하지 않는 것처럼 보입니다. 이것을 어떻게 돌리시겠습니까?
<?php
include_once("connect.php");
class Image
{
public static function uploadImage($formname,$query,$params)
{
$formname = "";
$response = "";
$image = "";
echo 'hello';
//if(file_exists($formname))
//{
echo 'hello';
$image = base64_encode(file_get_contents($_FILES[$formname]['tmp_name']));
//}
$options = array('http'=>array(
'method'=>"POST",
'header'=>"Authorization: Bearer access code here\n".
"Content-Type: application/x-www-form-urlencoded",
'content'=>$image
));
$context = stream_context_create($options);
$imgurURL = "https://api.imgur.com/3/image";
if ($_FILES[$formname]['size'] > 10240000) {
die('Image too big, must be 10MB or less!');
}
//if(file_exists($formname))
//{
echo 'hell0';
$response = file_get_contents($imgurURL, false, $context);
//}
$response = json_decode($response);
//from
//$prearams = array($formname=>$response->data->link);
//$params = $preparams + $params;
//from changes
//$params=array(':postid'=>$postid);
$params = array(':postid' => $params['postid'], ':postimg' => $params['postimg']);
connect::query($query,$params);
}
}
?>
"$ formname"은 여기에서 설정을 해제합니까? $ formname = ""; 메쏘드 호출에서 그것을 전달하면 상관 없습니다. 항상 비어 있습니다. – espradley
와우 나는 단지 눈의 신선한 쌍이 필요하다고 생각한다. – Bubba
덕분에 공식 답변으로 추가되었다. 해결책을 표시했다면 고맙겠습니다. – espradley