I'm working on a website using codeigniter and I'm trying to use Froala Editor to upload image in a textarea. it's all working fine until I try to upload the image files to my local folder instead of the default http://i.froala.com/upload
this is my html file:
<textarea id="my_editor" name="my_editor" class="editor">
</textarea>
<script>
$(function() {
$('.editor').froalaEditor({
imageUploadURL: "test/froala_upload",
})
});
</script>
and this is the froala_upload
function in my Test
controller file:
function froala_upload() {
// Allowed extentions.
$allowedExts = array("gif", "jpeg", "jpg", "png", "blob");
// Get filename.
$temp = explode(".", $_FILES["file"]["name"]);
// Get extension.
$extension = end($temp);
// Generate new random name.
$name = sha1(microtime()) . "." . $extension;
// Save file in the uploads folder.
move_uploaded_file($_FILES["file"]["tmp_name"], getcwd(). "/assets/review/" . $name);
// Generate response.
$response = new StdClass;
$response->link = "/assets/review/" . $name;
echo stripslashes(json_encode($response));
}
I deliberately omitted the image checking with finfo
which is used in most documentation about Froala Image Upload because some people say that it could be the problem - yet I'm still unable to upload the image file. and the error message was very helpful: "Something went wrong. Please try again"
I've spent hours scratching my head over this thing. and there is literally no full code solution for this problem on the great wide world of Internet so I can't find out what I'm doing wrong. can anyone help me with this?