Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Oct 2005
    Posts
    2
    Member #
    11512
    <?php
    include("config.inc.php");

    // initialization
    $result_final = "";
    $counter = 0;
    $images_dir = "photos";

    // 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();

    echo "New id=".$new_id;
    echo "<br>";

    $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 );

    echo "Width=".$size[0];
    echo "<br>";
    echo "Length=".$size[1];
    echo "<br>";

    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;
    }

    echo "destination dir=".$images_dir."/".$filename ;
    echo "<br>";
    // Build Thumbnail with GD 1.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 );
    $source_handle = $function_to_read ( "photos/".$filename );

    echo "Function To read =".$source_handle;
    echo "<br>";


    if($source_handle)
    {
    echo "Insdide Source Handle=";
    echo "<br>";

    // Let's create an blank image for the thumbnail
    $destination_handle = ImageCreate ( $thumbnail_width, $thumbnail_height );

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

    // Let's save the thumbnail
    $res = $function_to_write( $destination_handle, $images_dir."/tb_".$filename );

    echo "Function To_write Handle=".$res;
    echo "<br>";
    ImageDestroy($destination_handle );
    //

    $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;
    ?>

    ******************************

    Everything works fine if I run the code locally but when I run the code on a remote server, no image is displayed in the browser.
    I can see that files are loaded into "photos" directory on the server side but no image in the browser.
    What is going wrong.
    any suggestions.
    thanks
    regards
    /rsasalm

  2.  

  3. #2
    Junior Member
    Join Date
    Oct 2005
    Posts
    2
    Member #
    11512
    Hi all again

    I found this gallery code example found at
    http://www.sitepoint.com/article/php...system-minutes

  4. #3
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    139 times
    Sounds like a permission problem with the folders.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 07:23 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com