Jump to content

Is it Possible? Please Read PHP Experts


netpants

Recommended Posts

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

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'];
?>  

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?

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.