0
자바 스크립트에서 PHP 파일을 호출하려고하는데 작동하지 않습니다. 오류는 없지만 예상대로 작동하지 않았습니다. 아래는 제 코드입니다.자바 스크립트에서 PHP 파일을 호출 할 수 없습니다.
자바 스크립트
function getImage() {
obj = document.getElementById('paste-image');
postTo = "http://clipboard.netau.net/Web/shoot.php";
image = obj.getClipboardImageURL(postTo);
if (image) {
url = "shots/" + image;
document.getElementById("target").src = url;
document.getElementById("url").value = document.getElementById("target").src; // to get full path, hack, I know ;)
document.getElementById("container").style.display = "";
}
}
shoot.php는
<?php
$filename = uniqid() . '.jpg';
$result = file_put_contents("./shots/" . $filename, file_get_contents('php://input'));
if (!$result) {
print "error";
exit();
}
echo $filename;
?>
나는 무료 호스팅의 코드를 업로드했습니다. clipboard.netau.net는
'# target'은 (는)'img' 태그입니까? 그렇다면 왜 shoot.php를 할당할까요? – tjameson
getClipboardImageURL과 같은 메소드가 없습니다. 이거 어디서 났니? http://pastebin.com/gJmeFGvK – Barmar
에서 코드를 복사 한 것 같습니다. http://lassebunk.dk/2009/07/19/using-the-clipboard-to-post-images/ –