링크 리다이렉트
직접적으로 링크를 이동하지 않고 리다이렉팅 하는 방법을 알아 봅시다.
https://americano-outer.cafe24.com/stats/api/selm.php?k=aT0yOTY5Jm89MjgmYT1lZWE1YzczYTQwJnQ9bA==
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Api_upload extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->helper(array('form', 'url'));
}
# 파일 업로드 수행
public function index()
{
self::init_file_upload();
self::proc_file_upload();
}
# 파일 업로드 관련 초기화
protected function init_file_upload()
{
$config['upload_path'] = '/var/www/html/ci.graphevent.com/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 1000;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
}
# 파일 업로드 진행
protected function proc_file_upload()
{
$files_name = $_FILES['userfile']['name'];
$files = $_FILES['userfile'];
# 파일 변수명이 배열 형태인지 구분하여 처리
if ( !is_array($files_name) )
{
self::_do_upload_one();
}
else if ( count($files_name) > 0 )
{
foreach ( $files_name as $key => $val ) {
$_FILES['userfile'] = array(
'name' => $files['name'][$key],
'type' => $files['type'][$key],
'tmp_name' => $files['tmp_name'][$key],
'error' => $files['error'][$key],
'size' => $files['size'][$key]
);
self::_do_upload_one();
}
}
}
# 파일 업로드 하나씩 처리
private function _do_upload_one () {
if ( ! $this->upload->do_upload('userfile'))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
}
}
}



