2013-08-07 6 views
0

에서 이미지 파일 이름을 사용하는 방법 redactor 편집기에서 이미지를 업로드하는 동안 이미지 이름을 현재 날짜 및 시간의 md5 암호화로 바꿉니다. 하지만 이미지 파일 이름을 사용하고 싶습니다.
현재 라이브 데모를 볼 수 있습니다 이미지 파일 이름이 bird.jpg 경우 http://imperavi.com/redactor/
그렇다면, 내가 편집기에서 업로드를 한 후 bird.jpg로 유지하려면, 대신에이 e1cbe0be9c301f7f73f3271a86508db3.jpg
이미지 업로드 방법 작품 같은 뭔가 :
redactor.js 파일이나 예를 들어, 부하에이 옵션을 설정하여 :redactor 편집기

<script type="text/javascript"> 
$(document).ready(
function() 
{ 
    $('#redactor_content').redactor({ 
     imageUpload: '/modules/upload.php' 
    }); 
} 
); 
</script> 

이의이 upload.php 파일 이미지를 처리한다고 가정하자. 그 코드는 다음과 같이 보일 수 있습니다 :

<?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 예 :

{ "filelink": "/images/img.jpg" } 

가 어떻게 이미지 이름 대신 MD5 데이터가되도록 $file을 유지하기를? 먼저 upload.php에서

답변

2

변경

$ 파일 = $의 dir.md5 (날짜 ('YmdHis')). 'JPG.';

에 $ 파일 = $ _FILES [ '파일'] [ '이름'];

당신은 당신이 그것을 작동 http://imperavi.com/redactor/docs/files/

+0

감사에서 문서를 확인할 수 있습니다 더 참조 용 $file

에서 파일 이름을 가져 ... – rakibtg

관련 문제