netpants Posted June 4, 2008 Share Posted June 4, 2008 Hi there, Please see my example below. I want to be able to go to a page and upload an image. Now when the image is upload php if possible will check the file size and format and create something based on that. Heres an example.... I upload a 124kb .gif image. The script recognizes the size and .gif images and produces lets say a unique smiley face or story character based on the size and file format. Of course it would not be totally unique as I would have to put in however many storys depending on the size so....if max file size is 1024 kb then I would have to create 1024 different storys times however many different file formats I have. So the system would see in the database oohh file size 112 kb .gif is this story or smiley and print it. Hope I explained it, as I am going to create a unique RPG game, where instead of someone creating a guy themselves they simple create a little image and upload it to get a unique monster or character. They could then build on the guy all based on what kind of images or files they upload. So lots of fun seeing what kind of guy they can come up with uploading different images or file types. Please let me know. Thanks Link to comment https://forums.phpfreaks.com/topic/108710-is-it-possible-please-read-php-experts/ Share on other sites More sharing options...
GingerRobot Posted June 4, 2008 Share Posted June 4, 2008 Yeah, its possible -- you can detect file sizes and mime types. Link to comment https://forums.phpfreaks.com/topic/108710-is-it-possible-please-read-php-experts/#findComment-557470 Share on other sites More sharing options...
chriscloyd Posted June 4, 2008 Share Posted June 4, 2008 Ya I would personaly store each story in a database so say when you upload a photo with the size of 1124kb .gif <?php $size1 filesize("me.gif"); //mysqlconnect up here $get_story = mysql_query("Select * From story where size = '".$size1."' "); $story = mysql_fetch_assoc($get_story); echo $story['story']; ?> Link to comment https://forums.phpfreaks.com/topic/108710-is-it-possible-please-read-php-experts/#findComment-557475 Share on other sites More sharing options...
netpants Posted June 4, 2008 Author Share Posted June 4, 2008 Hmm Thanks Chris... So when I setup a form for people to upload a image or file or whatever ... it needs to take the file size and format and store it so it can look into the database for the exact match... So me.gif would be the uploaded file someone uploaded it took the name from the file name then its looking at the file size and Selecting from the database where the file size matches something in the size table ...am i right? Link to comment https://forums.phpfreaks.com/topic/108710-is-it-possible-please-read-php-experts/#findComment-557484 Share on other sites More sharing options...
chriscloyd Posted June 4, 2008 Share Posted June 4, 2008 yes your right Link to comment https://forums.phpfreaks.com/topic/108710-is-it-possible-please-read-php-experts/#findComment-557547 Share on other sites More sharing options...
discomatt Posted June 4, 2008 Share Posted June 4, 2008 If you're not using the original uploaded file afterwards, a great way would be to simply store the filesize rounded to the nearest kB into the database $kb = round( $bytes / 1024 ); # If it's bigger than 1024 kB, randomize it! if ( $kb > 1024 ) $kb = mt_rand( 1, 1024 ); You can then have a database filled with 1024 'story characters' each with an id of 1-1024, and use that as a parent table. The uploaded image will be deleted at the end of the scripts execution. Link to comment https://forums.phpfreaks.com/topic/108710-is-it-possible-please-read-php-experts/#findComment-557622 Share on other sites More sharing options...
netpants Posted June 4, 2008 Author Share Posted June 4, 2008 Great thanks everyone. Now to find a php programmer I could do it myself probably but it would take mee wayyyyyy to long heh. Link to comment https://forums.phpfreaks.com/topic/108710-is-it-possible-please-read-php-experts/#findComment-557698 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.