如何更改Redactor图像上传文件名?

时间:2015-08-03 13:24:30

标签: javascript php session renaming redactor

我有问答网站,我使用redactor

但是因为我想根据主题和日期监控上传的图像。 如何更改redactor上传图片的imagename?

$ subject是我的主题标题的变量名称 使用此代码

<?php
$dir = '/sitecom/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
$filename = $subject.md5(date('YmdHis')).'.jpg';
$file = $dir.$filename;

// copying
copy($_FILES['file']['tmp_name'], $file);

// displaying file
$array = array(
    'filelink' => $sysUrl.'/assets/uploads/r/'.$filename
);

echo stripslashes(json_encode($array));

}

?>

0 个答案:

没有答案