첨부파일을 두가지 용도로 쓰려고 합니다.

첨부파일을 두가지 용도로 쓰려고 합니다.

QA

첨부파일을 두가지 용도로 쓰려고 합니다.

답변 2

본문

안녕하세요.

지역회사나 점포 소개 사이트를 만들고 있는데요.

지금 보드 스킨을 구입해서 사용하고 있는데요.

 

스킨에서 첨부파일을 이미지로 받아서 이미지 갯수만큼 슬라이드로 보여줍니다.

 

그런데

pdf 파일을 추가로 첨부저장해서

다운로드할 수 있게 하고 싶은데....

 

첨부파일을 어떻게 하면 좋을까요?

가령 슬라이드 이미지 4개로 하고 

브로셔 국문용 영문용 pdf 각각 하나씩... 다운로드 할 수 있게 하려면 어케하면 좋을까요?

 

이 질문에 댓글 쓰기 :

답변 2

그누보드에서는 이미지가 아닌 것은 다운로드 링크가 자동으로 만들어 집니다

이미지만 슬라이드 되게 하면 되는데 그누보드가 아닌가요?

 

./download.php 해당 파일을 추가하여 아래 코드를 넣으면 파일 다운로드가 가능하게 개발이 가능합니다.

get 형태로 변수를 추가하여 변수별 파일을 선택가능하도록 하여 개발해보시기 바랍니다.

 

해당 소스는 

http://www.ciboard.co.kr/user_guide/kr/helpers/download_helper.html

코드이그나이터 소스를 가져온 것입니다.

 




function force_download($filename = '', $data = '', $set_mime = FALSE)
{
    if ($filename === '' OR $data === '')
    {
        return;
    }
    elseif ($data === NULL)
    {
        if ( ! @is_file($filename) OR ($filesize = @filesize($filename)) === FALSE)
        {
            return;
        }

        $filepath = $filename;
        $filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename));
        $filename = end($filename);
    }
    else
    {
        $filesize = strlen($data);
    }
    // Set the default MIME type to send
    $mime = 'application/octet-stream';

    $x = explode('.', $filename);
    $extension = end($x);

    if ($set_mime === TRUE)
    {
        if (count($x) === 1 OR $extension === '')
        {
            /* If we're going to detect the MIME type,
             * we'll need a file extension.
             */
            return;
        }

        // Load the mime types
        $mimes =& get_mimes();

        // Only change the default MIME if we can find one
        if (isset($mimes[$extension]))
        {
            $mime = is_array($mimes[$extension]) ? $mimes[$extension][0] : $mimes[$extension];
        }
    }

    /* It was reported that browsers on Android 2.1 (and possibly older as well)
     * need to have the filename extension upper-cased in order to be able to
     * download it.
     *
     * Reference: http://digiblog.de/2011/04/19/android-and-the-download-file-headers/
     */
    if (count($x) !== 1 && isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/Android\s(1|2\.[01])/', $_SERVER['HTTP_USER_AGENT']))
    {
        $x[count($x) - 1] = strtoupper($extension);
        $filename = implode('.', $x);
    }

    if ($data === NULL && ($fp = @fopen($filepath, 'rb')) === FALSE)
    {
        return;
    }

    // Clean output buffer
    if (ob_get_level() !== 0 && @ob_end_clean() === FALSE)
    {
        @ob_clean();
    }

    // Generate the server headers
    header('Content-Type: '.$mime);
    header('Content-Disposition: attachment; filename="'.$filename.'"');
    header('Expires: 0');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: '.$filesize);
    header('Cache-Control: private, no-transform, no-store, must-revalidate');

    // If we have raw data - just dump it
    if ($data !== NULL)
    {
        exit($data);
    }

    // Flush 1MB chunks of data
    while ( ! feof($fp) && ($data = fread($fp, 1048576)) !== FALSE)
    {
        echo $data;
    }

    fclose($fp);
    exit;
}

$download_file_path = "{$_SERVER['DOCUMENT_ROOT']}/index.php";


force_download($download_file_path, null);

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
  • 질문이 없습니다.
전체 0
© SIRSOFT
현재 페이지 제일 처음으로