Could anyone please help me get a video gallery script going on my website? I could pay a little and I would be very grateful.
Regards
Could anyone please help me get a video gallery script going on my website? I could pay a little and I would be very grateful.
Regards
Hey everyone, I absolutly love this gallery and have used some of the codes already suggested here including the Administration page which I think is excellent.
I have customized my gallery to allow for comments on photos and have just made an RSS Feed out of the gallery. I don’t believe anyone has released code to do either of these so I will release the RSS Feed generator first and then depending on how I did with QA’ing how it works release the comments program as well.
This program is very simple and only requires you to change a few variables, add a field to your categories table and then the program does the rest. It takes a set number of recently updated categories then the most recently added photos from the gallery.
To see an example of it visit:
http://www.kbasarab.com/gallery then subscribe to the photo gallery RSS Feed.
You find download the program from my site’s blog.
Hey all,
A new design I’m working on needs a little bit of… oh, I dunno. Anyway, what I’m looking for this this: thumbnails in a CSS embedded field (don’t worry, i got the square crop figured out), which point at the main image. However, when you click the thumb, the main image changes, but the physical URL does not.
I’ve enclosed an example image of what I mean to clarify. I’m mostly after the thumbnails on the same page with the URL not changing. example
Any pointers, hints, or sucks-to-be-you’s will be appreciated.
Not sure waht you are wanting here
The example is static and nothing is clickable
I guess you want to click on a thumbnail and display the larger image
Bill007
yeah the image is just a visual. And my goal is what you suggested. Click the smaller one, and appears as a larger one. I just dont want the page URL to change when I do it. I know it can be done, I just forget how. Even if someone has seen an example online somewhere, that’d be a good launching point for me.
did i read somewhere that a thumbnail generated automatically will be as large as the original?
Renikdelan - are you looking for an “imageswap” type of thing similar to this?:
http://www.gr0w.com/articles/imageswapper.php
Of course, that one is not based on a database driven gallery - unfortunately.
I’ve been trying to implement something like this with the Gallery but haven’t been able to do so yet.
Let me know if you have any luck.
Yeah I was looking for something like that. The only problem with that example is they shrink the original image in the php/html code for the thumbnail. If I/we can overcome that by drawing from the sql database, then damn.
After thinking about it more, the SP Gallery thumbnails wouldnt be too bad to replace the array that they have. The more concerning part is getting the images that are of decent size to load at a fairly quick rate… perhaps if the fullsize images could be converted to SWF during the upload, then put a preloader for it on the page? I think I remember Infizi working on something like that, but havent seen him in a while… any ideas?
You could try using an iframe to load the larger photos? Or you check out Jeroen Wijerings PHP image gallery. He uses JavaScript to load the new images, it may help you.
Also, what do I need to change to able to allow GIF files to be uploaded?? Thanks
Hello can anybody help, I found this code excellent but I now have a problem each time I submit the Add photso form I can see that upload.php has been called but it is running very slow, I eventually get the ‘cannot display page error’ and no data or images are uploaded to my web server. Here is the code from my upload.php file and the preupload.php.
Any help would be appreciated
Thanks in advance
UPLOAD.PHP
<?php
//Fetch the image array sent by preupload.php
$photos_uploaded=$_FILES['photo_filename'];
//Fetch the image names array
$photo_name=$_POST['photo_name'];
//Fetch the image captions array
$photo_caption=$_POST['photo_caption'];
//set an array for file types
$photo_types=array(
'image/pjpeg'=>'jpg',
'image/jpeg'=>'jpg',
'image/gif'=>'gif',
'image/bmp'=>'bmp',
'image/x-png'=>'png'
);
//validate the uploaded file is an image
while ($counter<=count($photos_uploaded))
{
if($photos_uploaded['size'][$counter]>0
{
if(!array_key_exists($photos_uploaded['type'][$counter],$photo_types))
{
$result_final.='File'.($counter+1).' is not a photo<br />';
}
else
{
$result_final.='File'.($counter+1).' was uploaded successfully.<br />';
}
}
}
//Add the new entry into the t_photos and fetch a unique ID
mysql_query("
INSERT INTO t_photos(
photo_name,
photo_caption,
photo_filename,
photo_cat
) VALUES (
'".$photo_name[$counter]."',
'".$photo_caption[$counter]."',
'0',
'".$_POST['category']."'
)
");
$new_id=mysql_insert_id(); //new id generated
//get the filetype of the uploaded file
$filetype=$photos_uploaded['type'][$counter];
//get the extension for the new name
$extension=$known_photo_types[$filetype];
//generate a new name
$filename="$new_id.$extension";
//update the filename in the database
mysql_query("
UPDATE t_photos SET
photo_filename='$filename'
WHERE photo_id='new_id'
");
//store the images
copy($photos_uploaded['tmp_name'][$counter],$images_dir.'/'.$filename);
move_uploaded_file($photos_uploaded['tmp_name'][$counter],$images_dir.'/'.$filename;
//create automatic thumbnails of images
//determine if the imag is a tall one or wide one
$size=GetImageSize($images_dir."/".$filename);
//Wide image
if($size[0]>$size[1])
{
$thumbnail_width=100;
$thumbnail_height=(int)(100*$size[1]/$size[0]);
}
//Tall image
else
{$thumbnail_height=100;
$thumbnail_width=(int)(100*$size[0]/$size[1]);
}
//set an array for file types
$gd_function_suffix=array(
'image/pjpeg'=>'jpg',
'image/jpeg'=>'jpg',
'image/gif'=>'gif',
'image/bmp'=>'bmp',
'image/x-png'=>'png'
);
//Get the name suffix on the basis of the mime type
$function_suffix=$gd_function_suffix[$filetype];
//Build the function name for ImageCreateFromSUFFIX
$function_to_read='ImageCreateFrom'.$function_suffix;
//Build function name for ImageSUFFIX
$function_to_write='Image'.$function_suffix;
//read the source file
$source_handle=$function_to_read($images_dir.'/'.$filename);
if($source_handle)
{
//Create a blank image for the thumbnail
$destination_handle=ImageCreateTrueColor($thumbnail_width,$thumbnail_height);
//resize it
ImageCopyResampled($destination_handle,$source_handle,0,0,0,0,$thumbnail_width,$thumbnail_height,$size[0],$size[1]);
}
//save the thumbnail
$function_to_write($destination_handle,$thumbs_dir.'/tb_'.$filename);
?>
PREUPLOAD.PHP
<?php
//phpinfo();
include '../dbconnect.php';
//initialisation
$photo_upload_fields='';
$counter=1;
//If we want more fields, the use preupload.php?number_of_fields=20
$number_of_fields=(isset($_GET['number_of_fields']))?(int)($_GET['number_of_fields']):5;
//Build the Category List
$result=mysql_query('SELECT cat_id,cat_name FROM t_category');
while ($row=mysql_fetch_array($result))
{
$photo_category_list.=<<<__HTML_END
<option value="$row[0]">$row[1]</option>\
__HTML_END;
}
mysql_free_result($result);
//Build the Image Uploading Fields
while($counter<=$number_of_fields)
{
$photo_upload_fields.=<<<__HTML_END
<tr>
<td align="right"><label>Photo {$counter}:</label></td>
<td><input name="photo_filename[]" type="file" size="50" class="txt" /></td>
</tr>
<tr>
<td align="right"><label>Photo Name:</label></td>
<td><input name="photo_name[]" type="text" size="50" class="txt"/></td>
</tr>
<tr>
<td align="right" valign="top"><label>Photo Caption:</label></td>
<td><textarea name="photo_caption[]" cols="50" rows="3" class="txt"></textarea>
<p></p></td>
</tr>
__HTML_END;
$counter++;
}
//Final Output
include '../top.php';
echo <<<__HTML_END
<body>
<div id="DB_Admin" align="center">
<form enctype="multipart/form-data" action="upload.php" method="post" name="upload_form">
<p class="adminTitle">DATABASE ADMINISTRATION - UPLOAD NEW PHOTOS</p>
<br>
<table width="500" align="center" cellpadding="2">
<tr><td colspan="2"><div align="center">
<label>Select Category</label>
<select name="category">
$photo_category_list
</select>
<p></p>
</div></td></tr>
<!-Insert image fields here-->
$photo_upload_fields
<tr><td colspan="2"><div align="center">
<br>
<input type="submit" name="submit" value="Add Photos" class="btn"></input>
<br>
</div></td></tr>
</table>
<div id="back">
<p><a href="index.php"> BACK <br>
</a></p>
</div>
</form>
</div>
</body>
__HTML_END;
include '../footer.htm';
?>
your upload.php file has no "include ‘…/dbconnect.php’;" to refer to the database config file.
Thanks for the advice, I included the line as you can see below and made a couple of other corrections as I found some missing brackets.
However, I still have the issue and when I eventually receive the ‘cannot display page’ error and refresh the page I receive the following error:-
Fatal error: Maximum execution time of 30 seconds exceeded in /home/wardkcou/public_html/fotoscapes/admin/upload.php on line 27
I don’t understand why I am getting this error.
Any ideas would be appreciated.
Thanks.
Here is the new code for my upload.php. Do I need to declare the $counter and have $counter++ in the while loop? Is this why I am getting the above error, I did try including these but the code still did not work.
<?php
include'../dbconnect.php';
//$counter=1;
//Fetch the image array sent by preupload.php
$photos_uploaded=$_FILES['photo_filename'];
//Fetch the image names array
$photo_name=$_POST['photo_name'];
//Fetch the image captions array
$photo_caption=$_POST['photo_caption'];
//set an array for file types
$photo_types=array(
'image/pjpeg'=>'jpg',
'image/jpeg'=>'jpg',
'image/gif'=>'gif',
'image/bmp'=>'bmp',
'image/x-png'=>'png'
);
//validate the uploaded file is an image
while ($counter<=count($photos_uploaded))
{
if($photos_uploaded['size'][$counter]>0)
{
if(!array_key_exists($photos_uploaded['type'][$counter],$photo_types))
{
$result_final.='File'.($counter+1).' is not a photo<br />';
}
else
{
$result_final.='File'.($counter+1).' was uploaded successfully.<br />';
}
}
//$counter++;
}
//Add the new entry into the t_photos and fetch a unique ID
mysql_query("
INSERT INTO t_photos(
photo_name,
photo_caption,
photo_filename,
photo_cat
) VALUES (
'".$photo_name[$counter]."',
'".$photo_caption[$counter]."',
'0',
'".$_POST['category']."'
)
");
$new_id=mysql_insert_id(); //new id generated
//get the filetype of the uploaded file
$filetype=$photos_uploaded['type'][$counter];
//get the extension for the new name
$extension=$photo_types[$filetype];
//generate a new name
$filename="$new_id.$extension";
//update the filename in the database
mysql_query("
UPDATE t_photos SET
photo_filename='$filename'
WHERE photo_id='new_id'
");
//store the images
copy($photos_uploaded['tmp_name'][$counter],$images_dir.'/'.$filename);
move_uploaded_file($photos_uploaded['tmp_name'][$counter],$images_dir.'/'.$filename);
//create automatic thumbnails of images
//determine if the imag is a tall one or wide one
$size= getimagesize($images_dir."/".$filename);
//Wide image
if($size[0]>$size[1])
{
$thumbnail_width=100;
$thumbnail_height=(int)(100*$size[1]/$size[0]);
}
//Tall image
else
{$thumbnail_height=100;
$thumbnail_width=(int)(100*$size[0]/$size[1]);
}
//set an array for file types
$gd_function_suffix=array(
'image/pjpeg'=>'jpg',
'image/jpeg'=>'jpg',
'image/gif'=>'gif',
'image/bmp'=>'bmp',
'image/x-png'=>'png'
);
//Get the name suffix on the basis of the mime type
$function_suffix=$gd_function_suffix[$filetype];
//Build the function name for ImageCreateFromSUFFIX
$function_to_read='imagecreatefrom'.$function_suffix;
//Build function name for ImageSUFFIX
$function_to_write='image'.$function_suffix;
//read the source file
$source_handle=$function_to_read($images_dir.'/'.$filename);
if($source_handle)
{
//Create a blank image for the thumbnail
$destination_handle=imagecreatetruecolor($thumbnail_width,$thumbnail_height);
//resize it
imagecopyresampled($destination_handle,$source_handle,0,0,0,0,$thumbnail_width,$thumbnail_height,$size[0],$size[1]);
}
//save the thumbnail
$function_to_write($destination_handle,$thumbs_dir.'/tb_'.$filename);
?>
Hi,
I seem to be able to upload images fine if there are of a certain size ie. photos of a 872x1536 dimension are OK but other photos I’ve tried of 640x421 or 2048x1536 dimension do not upload correctly. One photo and its thumbnail seems to upload fine but when I try 2 or more the second thumbnail is not created but both images are uploaded OK. Then when I try more than 2 photos upload.php gives a blank page.
Any ideas??
puzzled. didn’t think the original code was working with me. no error messages but the upload.php result came back with an empty (red x) image…and gave a positive result for file 1 being loaded. checked my image file, checked my db table: nothing! After wading through 10 pages of this thread I got it into my head to check for the thumbs. i was oddly relieved to find them under c:, but here are my problems:
i’m using dreamweaver and want the images to end up in a subfolder of my images folder - how much of a path do i need? i’m assuming it should be everything under the sitename (ie images/properties/thumbs/filename ).
my thumb was just named ‘tb_’ under c:.
i think i should be able to work this out myself but nobody semed to have had these probs before. still, i would appreciate any input.
cheers
h.
WOW! its wonderful, (almost) everything works perfect
i just don’t know how to use those added functions… where do i put it and how do i call it ( Like through a button? )
Hey guys. Long time! Yeh i been studing hard at uni so stopped PHPing as much. But annoying really. Ive started to have some free time, so geting back into it by launching a number of websites. Hopefully all done in the next 2 months (keep an eye on my tag).
Anyhoo. I did what your after when i made a showcase website for my brother.
I managed to get thumbnails to directly load the image. Is what i didnt implement but was hoping too last was making the thumbnails scrollable so it would be a gallery in a page.
I did some searching and found the best method to do this was AJAX. After a little search i understood it, and implemented it.
The code at the top is a fade method. Plus some other cool image functions i experimented with. I havent yet fully put this into the ajax script (Near bottom of the page), would be cool to have a fade! Its almost there too, just needs a few lines added if you want me to??
Right, you need each link like this:
<a href="javascript:swapImg('Img_ID_to_update', 'img_id_to_insert(fromDB)');><img src='thumbnail.....'></a>
In the code you need to add the DIV id that the image will sit in. This, ideally is just a container for the image and nothing else.
Also, you need a file called getimage.php which will get from the data base the details of the requested image, and passback in the form of echo-ing
img_src|||img_width|||img_height
if you look you can see how you could send more or less variables!
As a final thought, you could also use the fade by calling swapImg in the ‘id’ variable for fade(), and do a bit of editing to make it change the src width and height.
Hope you enjoy it, any quesitions just ask
For anyone that is having a problem such as the one above.
i.e. Only able to upload a few images no matter what the size of the files.
This is NOT a configuration problem, it is an error in the coding in upload.php that is reflected in versions of PHP that do not support registered gobals.
Problem: Improper use of the count function.
the original upload.php code:
// 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) )
In order to properly count the $_FILES array you must use a statement such as:
count($_FILES[‘photo_filename’][‘tmp_name’])
The working upload.php code:
// 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($_FILES['photo_filename']['tmp_name']) )
Hi… Ive been playing with these files, and looking to implement this on a site im messing with ATM… But i do have a question or two.
The first regards the ‘photos’ folder. You have to leave the ‘photos’ folder chmod 777, from what I understand? Doesnt this leave that folder wide open, security-wise?
Secondly, if so, is there a way to have upload.php change the folder permissions to 777 before the files are copied, then set it back to 644 afterwards?
Im a relative PHP newbie (im upto about 13hrs now ), so i hope what im asking makes sense!
So far what i’m working to do is have the upload components in a password protected folder, accessing the DB with a usr that has full rights to the DB… The view components with be in a public folder, accessing the DB thru a usr with minimal rights. Whilst i havent finished this yet, i see no reason why it shouldnt play ball.
Im just not sure about the photo’s folder. I can of course just FTP in and change the folder permissions, but i am hoping to be able to make the upload as easy as possible for non-skilled ppl to use, whilst keeping the folder secure.
Sorry if this is dumb and n00b…
when i execute the preupload file,
the following output appears on ie explorer :
$row[1]
__HTML_END; } mysql_free_result($result); // Lets build the Image Uploading fields while($counter <= $number_of_fields) { $photo_upload_fields .= <<<__HTML_END Photo {$counter}: Caption: __HTML_END; $counter++; } // Final Output echo <<<__HTML_END
Select Category $photo_category_list
$photo_upload_fields
__HTML_END; ?>
anything that i have done wrongly ?
could it be the preupload.php cannot execute in php5.1 version ?
please help
Yup
CHMOD the folder before the file is moved and then CHMOD it back again
Dont worry, it does
Can you post the code that this is contained in?
what is before $row[1]
__HTML_END;?
It might be an idea to start a thread of your own about this, it might get answered more promptly
Spike