SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why the picture is not showing?

    I am trying out the gallery system.
    but in viewgallery.php it shows all except the picture and instead of picture It shows X marks.
    Why the image is not showing?

    and in the time of uploaing it shows(I am using Php 5.0.1 ,gd 2.x.x)
    These warning
    PHP Code:
    [COLOR=Red]
    Warningcopy(photos/7.jpg) [function.copy]: failed to open streamNo such file or directory in d:\www\image\upload.php on line 51

    Warning
    getimagesize(photos/7.jpg) [function.getimagesize]: failed to open streamNo such file or directory in d:\www\image\upload.php on line 54

    Warning
    Division by zero in d:\www\image\upload.php on line 62

    Warning
    imagecreatefromjpeg(photos/7.jpg) [function.imagecreatefromjpeg]: failed to open streamNo such file or directory in d:\www\image\upload.php on line 72

    Warning
    imagejpeg(): supplied argument is not a valid Image resource in d:\www\image\upload.php on line 85
     File 1 Added
    [/COLOR
    Advanced thanks for u'r help
    -::Ujjwal::-
    Visit My Site

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    You need to post the code, but, from the error messages I would say you have a permissions problem on the folder you are trying to copy into. The easiest way to work with uploaded files is to use the: move_uploaded_file() function http://www.php.net/move_uploaded_file

    HTH

    Andrew

  3. #3
    SitePoint Addict toggg's Avatar
    Join Date
    Jan 2005
    Location
    Auvergne/France
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    It's just the path to your folder photos not correct certainly.
    What gallery is it ?
    +
    bertrand Gugger toggg.com linux, PHP, Auvergne/France open source

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd disagree, the system is failing to copy the image, this is usually always caused by incorrect permissions.

  5. #5
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    o.k. I am using here in localhost and using winxp and apache webserver 2.5.1
    I have just created folder image under www folder.Is it wrong?

    How to change a folder in 777 mode in windows.
    Is there any options?

    This is upload.php
    PHP Code:
    <?php
        
    include("config.inc.php");

        
    // initialization
        
    $result_final "";
        
    $counter 0;

        
    // List of our known photo types
        
    $known_photo_types = array( 
                            
    'image/pjpeg' => 'jpg',
                            
    'image/jpeg' => 'jpg',
                            
    'image/gif' => 'gif',
                            
    'image/bmp' => 'bmp',
                            
    'image/x-png' => 'png'
                        
    );
        
        
    // GD Function List
        
    $gd_function_suffix = array( 
                            
    'image/pjpeg' => 'JPEG',
                            
    'image/jpeg' => 'JPEG',
                            
    'image/gif' => 'GIF',
                            
    'image/bmp' => 'WBMP',
                            
    'image/x-png' => 'PNG'
                        
    );

        
    // Fetch the photo array sent by preupload.php
        
    $photos_uploaded $_FILES['photo_filename'];

        
    // Fetch the photo caption array
        
    $photo_caption $_POST['photo_caption'];

        while( 
    $counter <= count($photos_uploaded) )
        {
            if(
    $photos_uploaded['size'][$counter] > 0)
            {
                if(!
    array_key_exists($photos_uploaded['type'][$counter], $known_photo_types))
                {
                    
    $result_final .= "File ".($counter+1)." is not a photo<br />";
                }
                else
                {
                    
    mysql_query"INSERT INTO gallery_photos(`photo_filename`, `photo_caption`, `photo_category`) VALUES('0', '".addslashes($photo_caption[$counter])."', '".addslashes($_POST['category'])."')" );
                    
    $new_id mysql_insert_id();
                    
    $filetype $photos_uploaded['type'][$counter];
                    
    $extention $known_photo_types[$filetype];
                    
    $filename $new_id.".".$extention;

                    
    mysql_query"UPDATE gallery_photos SET photo_filename='".addslashes($filename)."' WHERE photo_id='".addslashes($new_id)."'" );

                    
    // Store the orignal file
                    
    copy($photos_uploaded['tmp_name'][$counter], $images_dir."/".$filename);

                    
    // Let's get the Thumbnail size
                    
    $size GetImageSize$images_dir."/".$filename );
                    if(
    $size[0] > $size[1])
                    {
                        
    $thumbnail_width 100;
                        
    $thumbnail_height = (int)(100 $size[1] / $size[0]);
                    }
                    else
                    {
                        
    $thumbnail_width = (int)(100 $size[0] / $size[1]);
                        
    $thumbnail_height 100;
                    }
                
                    
    // Build Thumbnail with GD 2.x.x, you can use the other described methods too
                    
    $function_suffix $gd_function_suffix[$filetype]; 
    $function_to_read 'ImageCreateFrom' $function_suffix
    $function_to_write 'Image' $function_suffix

    // Read the source file 
    $source_handle $function_to_read($images_dir '/' $filename); 
            
    if (
    $source_handle) { 
     
    // Let's create a blank image for the thumbnail 
     
    $destination_handle 
       
    ImageCreateTrueColor($thumbnail_width$thumbnail_height); 

     
    // Now we resize it 
     
    ImageCopyResampled($destination_handle$source_handle
       
    0000$thumbnail_width$thumbnail_height$size[0], $size[1]); 


    // Let's save the thumbnail 
    $function_to_write($destination_handle$images_dir '/tb_' $filename);


                    
    $result_final .= "<img src='".$images_dir"/tb_".$filename."' /> File ".($counter+1)." Added<br />";
                }
            }
        
    $counter++;
        }

        
    // Print Result
    echo <<<__HTML_END

    <html>
    <head>
        <title>Photos uploaded</title>
    </head>
    <body>
        
    $result_final
    </body>
    </html>

    __HTML_END;
    ?>
    -::Ujjwal::-
    Visit My Site

  6. #6
    SitePoint Addict toggg's Avatar
    Join Date
    Jan 2005
    Location
    Auvergne/France
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure !
    My "path to your folder photos not correct" was meant very largely
    But you're right it's a common pitfall.
    +
    bertrand Gugger toggg.com linux, PHP, Auvergne/France open source

  7. #7
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have seen that picture is not available in my rdbms
    -::Ujjwal::-
    Visit My Site

  8. #8
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello all,
    This time i have created a folder photos.and under all the files
    and shows this warnning
    PHP Code:
    Warningcopy(photos/10.jpg) [function.copy]: failed to open streamNo such file or directory in d:\www\photos\upload.php on line 51

    Warning
    getimagesize(photos/10.jpg) [function.getimagesize]: failed to open streamNo such file or directory in d:\www\photos\upload.php on line 54

    Warning
    Division by zero in d:\www\photos\upload.php on line 62

    Warning
    imagecreatefromjpeg(photos/10.jpg) [function.imagecreatefromjpeg]: failed to open streamNo such file or directory in d:\www\photos\upload.php on line 72

    Warning
    imagejpeg(): supplied argument is not a valid Image resource in d:\www\photos\upload.php on line 85
     File 1 Added 
    anybody plz guide me what to do?
    -::Ujjwal::-
    Visit My Site

  9. #9
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by toggg
    Sure !
    My "path to your folder photos not correct" was meant very largely
    But you're right it's a common pitfall.
    +
    Hello sir,
    In upload.php there is temporary file.I have to crate it?
    Plz guide me?
    -::Ujjwal::-
    Visit My Site


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •