Pagina 1 din 1

Script $thumbnail_link eroare

Scris: Vin Sep 02, 2011
de onu
Salut , am si eu o problema la acest script.
localhost.php on line | mai exact
Warning: copy() [function.copy]: Unable to access in /home/undeva/public_html/admin/src/localhost.php on line 38
// try copying it... if it fails, go to backup method.
if(!copy($thumbnail_link, $upload_path . $thumb_name ))

trebuie sa adaug cv , sau :| ..
habar nu am

Cod: Selectaţi tot

<?php
if(!defined('PHPMELODY'))
    die('Restricted Access!');

function download_thumb($thumbnail_link, $upload_path, $video_uniq_id) {
    $last_ch = substr($upload_path, strlen($upload_path)-1, strlen($upload_path));
    if($last_ch != "/")
        $upload_path .= "/"; 

    $ext = ".jpg";
    
    $thumb_name = $video_uniq_id . "-1" . $ext;
    
    if(is_file( $upload_path . $thumb_name )) {
        return FALSE;
    }
    
    $error = 0;
    if( ini_get('allow_url_fopen') == 1 )
    {
        // try copying it... if it fails, go to backup method.
        if(!copy($thumbnail_link, $upload_path . $thumb_name ))
        {
            //    create a new image
            list($img_width, $img_height, $img_type, $img_attr) = @getimagesize($thumbnail_link);

            $image = '';

            switch($img_type)
            {
                case 1:
                    //GIF
                    $image = imagecreatefromgif($thumbnail_link);
                    $ext = ".gif";
                break;
                case 2:
                    //JPG
                    $image = imagecreatefromjpeg($thumbnail_link);
                    $ext = ".jpg";
                break;  
                case 3:
                    //PNG
                    $image = imagecreatefrompng($thumbnail_link);
                    $ext = ".png";
                break;
            }
            
            $resource = @imagecreatetruecolor($img_width, $img_height);
            if( function_exists('imageantialias'))
            {
                @imageantialias($resource, true); 
            }
            
            @imagecopyresampled($resource, $image, 0, 0, 0, 0, $img_width, $img_height, $img_width, $img_height);
            @imagedestroy($image);
        }
        
        $thumb_name = $video_uniq_id . "-1" . $ext;
        
        $img_type = 2;
        switch($img_type)
        {
            default:
            case 1:
                //GIF
                @imagegif($resource, $upload_path . $thumb_name);
            break;
            case 2:
                //JPG
                @imagejpeg($resource, $upload_path . $thumb_name);
            break;  
            case 3:
                //PNG
                @imagepng($resource, $upload_path . $thumb_name);
            break;
        }
        
        if($resource === '')
            $error = 1;
    }
    elseif( (ini_get('allow_url_fopen') == 1 && $error == 1) || ini_get('allow_url_fopen') == 0 )
    {    
        if ( function_exists('curl_init') ) {

            $ch = curl_init();
            $timeout = 0;
            curl_setopt ($ch, CURLOPT_URL, $thumbnail_link);
            curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
            
            // Getting binary data
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
            
            $image = curl_exec($ch);
            curl_close($ch);
            
            //    create & save image;
            $img_res = @imagecreatefromstring($image);
            if($img_res === false)
                return FALSE;
            
            $img_width = imagesx($img_res);
            $img_height = imagesy($img_res);
            
            $resource = @imagecreatetruecolor($img_width, $img_height);
            
            if( function_exists('imageantialias'))
            {
                @imageantialias($resource, true); 
            }
            
            @imagecopyresampled($resource, $img_res, 0, 0, 0, 0, $img_width, $img_height, $img_width, $img_height);
            @imagedestroy($img_res);
        
            switch($ext)
            {
                case ".gif":
                    //GIF
                    @imagegif($resource, $upload_path . $thumb_name);
                break;
                case ".jpg":
                    //JPG
                    @imagejpeg($resource, $upload_path . $thumb_name);
                break;  
                case ".png":
                    //PNG
                    @imagepng($resource, $upload_path . $thumb_name);
                break;
            }
        } 
    }
    return $upload_path . $thumb_name;
}

function do_main(&$video_details, $url)
{
    return true;
}
?>
Multumesc

Script $thumbnail_link eroare

Scris: Sâm Sep 03, 2011
de MarPlo
Salut
Nu stiu care sa fie problema, acea linie de cod e corecta.
Cand se apeleaza functia download_thumb() trebuie sa adaugi 3 argumente, pt. cei trei parametri: ($thumbnail_link, $upload_path, $video_uniq_id), de asemenea, verifica sa ai permisiuni de scriere in directorul adaugat pt. $upload_path (CHMOD 0777).