while uploading an image in redactor editor, it itself rename the image file name with md5 encryption of current date and time. But i want to use the image file name.
You can see a live demo here: http://imperavi.com/redactor/
So, if a image file name is bird.jpg
then i want to keep it as bird.jpg
after upload it in editor, instead of something like this e1cbe0be9c301f7f73f3271a86508db3.jpg
How Images upload Works:redactor.js
file or by setting this option on load, for example:
<script type="text/javascript">
$(document).ready(
function()
{
$('#redactor_content').redactor({
imageUpload: '/modules/upload.php'
});
}
);
</script>
Let's assume that upload.php
file will handle images. Its code may look like this:
<?php
// files storage folder
$dir = '/home/web/sitecom/redactor/images/';
$_FILES['file']['type'] = strtolower($_FILES['file']['type']);
if ($_FILES['file']['type'] == 'image/png'
|| $_FILES['file']['type'] == 'image/jpg'
|| $_FILES['file']['type'] == 'image/gif'
|| $_FILES['file']['type'] == 'image/jpeg'
|| $_FILES['file']['type'] == 'image/pjpeg')
{
// setting file's mysterious name
$file = $dir.md5(date('YmdHis')).'.jpg';
// copying
move_uploaded_file($_FILES['file']['tmp_name'], $file);
// displaying file
$array = array(
'filelink' => '/images/'.$file
);
echo stripslashes(json_encode($array));
}
?>
JSON example:
{ "filelink": "/images/img.jpg" }
so how to keep the $file
to be the image name instead of the md5 data?