Error code when uploading JPG files?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jonathan
    Senior Member
    • Mar 2004
    • 1229

    #1

    Error code when uploading JPG files?

    OK long story short - been a LOOOoonnnngg time since I messed with
    PHP/MySQL/web design in general/etc. So I went to SitePoint.com and
    read up on their article about a PHP gallery. All I want for my latest site
    is a splash screen with 4 links to the categories. For now that script suits
    my needs. But I am getting errors. I have done the following...

    1) Reset 'gallery' permissions to 777
    2) Ensured 'my-URL.com/gallery' was the image directory.
    3) Ensured 'my-URL.com/' was used in any links
    4) Ensured MySQL database, table, etc. names ALL match up

    No images are being put into the 'gallery' folder, however....
    I'm getting the info put into my database... but getting these errors:

    Code:
    Warning: copy(/5.jpg) [function.copy]: failed to open stream: Permission denied in /home/user/public_html/admin/upload.php on line 63
    
    Warning: getimagesize(/5.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /home/user/public_html/admin/upload.php on line 66
    
    Warning: Division by zero in /home/user/public_html/admin/upload.php on line 74
    
    Warning: imagecreatefromjpeg(/5.jpg) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /home/user/public_html/admin/upload.php on line 84
    
    Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/user/public_html/admin/upload.php on line 96
    
    Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/user/public_html/admin/upload.php on line 97
    File 1 Added
    SP article: http://www.sitepoint.com/article/php...system-minutes

    Any ideas??
    "How can someone be so distracted yet so focused?"
    - C
  • Elite
    Senior Member
    • Apr 2004
    • 168

    #2
    I think you path should be: /home/USERNAME/public_html/

    Where USERNAME is your dathorn username

    rather than: /home/user/public_html/

    Also, I think you only need to chmod to 755??

    HTH

    Comment

    • ZYV
      Senior Member
      • Sep 2005
      • 315

      #3
      In fact I do not think he needs to chmod anything at all.

      Comment

      • Jonathan
        Senior Member
        • Mar 2004
        • 1229

        #4
        OK - with still keeping the 'gallery' folder @ 777, I re did the path as suggested.
        Now that is all fixed. I just need to go back through, I think I missed a part because
        while the categories display (as links [though on main page I use 4 main pictures])
        I cannot get any pictures to display. I try typing direct URL in but I just keep my site
        with the caption I put in, but no picture. Its probably simple...

        I'll be keeping you guys updated on the progress, so expect to hear back soon LOL
        "How can someone be so distracted yet so focused?"
        - C

        Comment

        • Jonathan
          Senior Member
          • Mar 2004
          • 1229

          #5
          OK. I cannot, for the life of me, find the problem in this code as to why it will NOT
          display the thumbnails when I click on the category of choice (with pics there!).
          I can go direct URL to the photo with the cid & pid (category & picture IDs) values
          in the URL, but then it only shows my caption not the photo (the full size one).

          Code:
          <?php
          	$title = "View Gallery";
          	require_once "head.php";
          	require_once "mysql_config.php";
          
             ?> 
          
          
          </table>
          <table id="content">
          
          <?php
          	// initialization
          	$result_array = array();
          	$counter = 0;
          
          	$cid = (int)($_GET['cid']);
          	$pid = (int)($_GET['pid']);
          
          	// Category Listing
          
          	if( empty($cid) && empty($pid) )
          	{
          		$number_of_categories_in_row = 4;
          
          		$result = mysql_query( "SELECT c.category_id,c.category_name,COUNT(photo_id)
          						FROM gallery_category as c
          						LEFT JOIN gallery_photos as p ON p.photo_category = c.category_id
          						GROUP BY c.category_id" );
          		while( $row = mysql_fetch_array( $result ) )
          		{
          			$result_array[] = "<a href='viewgallery.php?cid=".$row[0]."'>".$row[1]."</a> "."(".$row[2].")";
          		}
          		mysql_free_result( $result );	
          
          		$result_final = "<tr>\n";
          
          		foreach($result_array as $category_link)
          		{
          			if($counter == $number_of_categories_in_row)
          			{	
          				$counter = 1;
          				$result_final .= "\n</tr>\n<tr>\n";
          			}
          			else
          			$counter++;
          
          			$result_final .= "\t<td>".$category_link."</td>\n";
          		}
          
          		if($counter)
          		{
          			if($number_of_categories_in_row-$counter)
          			$result_final .= "\t<td colspan='".($number_of_categories_in_row-$counter)."'>&nbsp;</td>\n";
          
          			$result_final .= "</tr>";
          		}
          	}
          
          
          	// Thumbnail Listing
          
          	else if( $cid && empty( $pid ) )
          	{
          		$number_of_thumbs_in_row = 5;
          
          		$result = mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."'" );
          		$nr = mysql_num_rows( $result );
          
          		if( empty( $nr ) )
          		{
          			$result_final = "\t<tr><td>No Category found</td></tr>\n";
          		}
          		else
          		{
          			while( $row = mysql_fetch_array( $result ) )
          			{
          				$result_array[] = "<a href='viewgallery.php?cid=$cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' /></a>";
          			}
          			mysql_free_result( $result );	
          
          			$result_final = "<tr>\n";
          	
          			foreach($result_array as $thumbnail_link)
          			{
          				if($counter == $number_of_thumbs_in_row)
          				{	
          					$counter = 1;
          					$result_final .= "\n</tr>\n<tr>\n";
          				}
          				else
          				$counter++;
          
          				$result_final .= "\t<td>".$thumbnail_link."</td>\n";
          			}
          	
          			if($counter)
          			{
          				if($number_of_photos_in_row-$counter)
          			$result_final .= "\t<td colspan='".($number_of_photos_in_row-$counter)."'>&nbsp;</td>\n";
          
          				$result_final .= "</tr>";
          			}
          		}
          	}
          
          	// Full Size View of Photo
          	else if( $pid )
          	{
          		$result = mysql_query( "SELECT photo_caption,photo_filename FROM gallery_photos WHERE photo_id='".addslashes($pid)."'" );
          		list($photo_caption, $photo_filename) = mysql_fetch_array( $result );
          		$nr = mysql_num_rows( $result );
          		mysql_free_result( $result );	
          
          		if( empty( $nr ) )
          		{
          			$result_final = "\t<tr><td>No Photo found</td></tr>\n";
          		}
          		else
          		{
          			$result = mysql_query( "SELECT category_name FROM gallery_category WHERE category_id='".addslashes($cid)."'" );
          			list($category_name) = mysql_fetch_array( $result );
          			mysql_free_result( $result );	
          
          			$result_final .= "<tr>\n\t<td>
          						<a href='viewgallery.php'>Categories</a> &gt; 
          						<a href='viewgallery.php?cid=$cid'>$category_name</a></td>\n</tr>\n";
          
          			$result_final .= "<tr>\n\t<td align='center'>
          					<br />
          					<img src='".$images_dir."/".$photo_filename."' border='0' alt='".$photo_caption."' />
          					<br />
          					$photo_caption
          					</td>
          					</tr>";
          		}
          	}
          
          // Final Output
          echo <<<__HTML_END
          
          <table width="750" border="0" align="center" style="width: 750px; text-align: center; border: 0xp; margin: 0px auto;">
          $result_final		
          </table>
          
          __HTML_END;
          ?>
          		
          		</td>
          	</tr>
          </table>
          
          <?php
          	require_once "foot.php";
          ?>
          Any clues??
          "How can someone be so distracted yet so focused?"
          - C

          Comment

          • Jonathan
            Senior Member
            • Mar 2004
            • 1229

            #6
            Got it fixed. Changing the $images_dir values resulting in it being able to
            upload fine. BUT then it trashed the URLs for the pages when you go to view
            either the thumbnails (at base of the category the user picked) or full size photo.

            So I made a new variable to use the direct HTTP:// url to the gallery, for
            all the <img> HTML tags the code outputs. Thanks all for the help
            "How can someone be so distracted yet so focused?"
            - C

            Comment

            Working...