Php 弗罗拉编辑器上传
您好,我正在使用froala编辑器,我可以将内容保存在我的数据库中,现在我正在尝试将图像上载到我的服务器,但我没有运气,到目前为止,我唯一的输出是“出现问题,请重试”。这是我的代码Php 弗罗拉编辑器上传,php,froala,Php,Froala,您好,我正在使用froala编辑器,我可以将内容保存在我的数据库中,现在我正在尝试将图像上载到我的服务器,但我没有运气,到目前为止,我唯一的输出是“出现问题,请重试”。这是我的代码 <body> <div id="editor"></div> </body> <script> $(function() { $('#editor').froalaEditor({ // Set the image uploa
<body>
<div id="editor"></div>
</body>
<script>
$(function() {
$('#editor').froalaEditor({
// Set the image upload URL.
imageUploadURL: 'save.php',
imageUploadParams: {
id: 'my_editor'
}
})
});
</script>
我正试图将上传的文件保存到服务器中名为upload_image的文件夹中。Hi!请粘贴表单的html部分。好的,那么依赖项是问题所在,包括扩展名php_imagick.dll。现在的问题是我无法在我的php.ini上添加此内容。我使用的是php版本5.6。为什么不能将其添加到php.ini中?托管提供商限制?这个链接正是我所经历的,但我使用的不是wamp而是xammp,请查看该帖子的第一个答案。Xampp和Wampp几乎相同,只是更改了用于控制流程的应用程序。你应该下载windows的二进制文件。嗨!请粘贴表单的html部分。好的,那么依赖项是问题所在,包括扩展名php_imagick.dll。现在的问题是我无法在我的php.ini上添加此内容。我使用的是php版本5.6。为什么不能将其添加到php.ini中?托管提供商限制?这个链接正是我所经历的,但我使用的不是wamp而是xammp,请查看该帖子的第一个答案。Xampp和Wampp几乎相同,只是更改了用于控制流程的应用程序。您应该下载windows的二进制文件。
// Allowed extentions.
$allowedExts = array("gif", "jpeg", "jpg", "png");
// Get filename.
$temp = explode(".", $_FILES["my_editor"]["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.
// Do not use $_FILES["file"]["type"] as it can be easily forged.
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES["my_editor"]["tmp_name"]);
if ((($mime == "image/gif")
|| ($mime == "image/jpeg")
|| ($mime == "image/pjpeg")
|| ($mime == "image/x-png")
|| ($mime == "image/png"))
&& in_array($extension, $allowedExts)) {
// Generate new random name.
$name = sha1(microtime()) . "." . $extension;
// Save file in the uploads folder.
move_uploaded_file($_FILES["my_editor"]["tmp_name"], getcwd() . "/upload_image/" . $name);
// Generate response.
$response = new StdClass;
$response->link = "/upload_image/" . $name;
echo stripslashes(json_encode($response));
}