0
내가 CakePHP를하고 mysql..my 코드가 실행되는 사용하여 이미지를 표시하려고를 사용하여 이미지를 표시하려고하지만 uploadsController이 ::는 CakePHP의 mysql을
<?php
class UploadsController extends AppController{
var $name='Uploads';
function share_video($stu_id=null)
{
$this->set('stu',$stu_id);
$tut=$this->Session->read('tutor_id');
$data=$this->Upload->query("select * from tutors AS Tutor where tutor_id='$tut'");
$this->set('val1',$data);
if (!empty($this->data)) {
\t \t \t \t \t $this->Upload->create();
\t \t \t \t \t if ($this->uploadFile() && $this->Upload->save($this->data)) {
\t \t \t \t \t \t $this->Session->setFlash(__('The upload has been saved', true));
\t \t \t \t \t \t //$this->redirect(array('action' => 'index'));
\t \t \t \t \t } else {
\t \t \t \t \t \t $this->Session->setFlash(__('The upload could not be saved. Please, try again.', true));
\t \t \t \t \t }
\t \t \t }
$data=$this->Upload->find('all');
$this->set('val2',$data);
$this->layout='tutor';
\t \t }
\t \t function uploadFile() {
$id = mysql_insert_id();
\t \t $file = $this->data['Upload']['file'];
if ($file['error'] === UPLOAD_ERR_OK) {
\t \t \t //$id = String::uuid();
\t \t \t if (move_uploaded_file($file['tmp_name'], APP.'webroot/uploads'.DS.$file['name'])) {
\t \t \t $this->request->data['Upload']['upload_id'] = $id;
\t \t \t $this->request->data['Upload']['filename'] = $file['name'];
\t \t \t $this->request->data['Upload']['filesize'] = $file['size'];
\t \t \t $this->request->data['Upload']['filemime'] = $file['type'];
\t \t \t return true;
\t \t \t }
\t \t }
\t \t return false;
\t \t
}
function download($filename=null)
{
$data=$this->Upload->find('all',array('conditions'=>array('filename'=>$filename)));
$this->set('val1',$data);
}
}
?>
내 download.ctp 파일은 다음과 같습니다.
Html-> image ('업로드 /'.$ val1 [0] [업로드'] [ '파일 이름']); URL '('컨트롤러 '=>'업로드 ','동작 '=>'다운로드 ', $ val1 [0] ['업로드 '] ['파일 이름 ']))' 폭 = "100"높이 = "100"/>; 업로드 /'.$ VAL1 [ '업'] [ '파일 이름']? 는 >
는 $ this->, HTML> 화상 (에코 ' 배열 ('클래스'=> '미디어 객체의 img IMG-썸네일', '고도'=> $ val1과 [ '업로드'] [ '이름']) \t \t \t \t) –
이 내 코드 –
이 시도 코드가 작동하지 않습니다 –