Froala Docs 으로 복사하여 (일부) 스크립트를 복사하고 편집했는데 어떻게 든 작동하지 않는 것처럼 보였습니다. 응답을받지 못했습니다.
upload.php로 : (내 웹 사이트에 포함)PHP/JS Froala imag 업로드가 제대로 작동하지 않습니다.
<?php
// Allowed extentions.
$allowedExts = array("gif", "jpeg", "jpg", "png");
// Get filename.
$temp = explode(".", $_FILES["file"]["name"]);
// Get extension.
$extension = end($temp);
// An image check is being done in the editor but it is best to
// check that again on the server side.
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& in_array($extension, $allowedExts)) {
// Generate new random name.
$name = sha1(microtime()) . "." . $extension;
// Save file in the uploads folder.
move_uploaded_file($_FILES["file"]["tmp_name"], getcwd() . "images/" . $name);
// Generate response.
$response = new StdClass;
$response->link = "images/" . $name;
echo stripslashes(json_encode($response));
}
?>
upload.js : 여기 내 코드의
$(function(){
$('#edit').editable({
// Set the image upload parameter.
imageUploadParam: 'file',
// Set the image upload URL.
imageUploadURL: '/upload.php',
// CORS. Only if needed.
crossDomain: false,
// Additional upload params.
imageUploadParams: {id: 'edit'},
// Set the image error callback.
imageErrorCallback: function (error) {
// Custom error message returned from the server.
if (error.code == 0) { error: 'My custom error message.' }
// Bad link.
else if (error.code == 1) { error: 'Bad link.' }
// No link in upload response.
else if (error.code == 2) { error: ' No link in upload response.' }
// Error during file upload.
else if (error.code == 3) { error: 'Error during file upload.' }
// Parsing response failed.
else if (error.code == 4) { error: 'Parsing response failed.' }
// Image too large.
else if (error.code == 5) { error: 'Image too large.' }
// Invalid image type.
else if (error.code == 6) { error: 'Invalid image type.' }
// Image can be uploaded only to same domain in IE 8 and IE 9.
else if (error.code == 7) { error: 'Image can be uploaded only to same domain in IE 8 and IE 9.' }
}
})
});
나는 해결책을 찾기 위해 사방 보였다하지만 문제가 여전히 미해결 인, 도와주세요 나, 나는 그것이