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

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.