Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,676 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,194 people online right now. Registration is fast and FREE... Join Now!




Recent Image Upload script

 
Reply to this topicStart new topic

Recent Image Upload script, Like what is at the bottom of TinyPic

Jamaal10
post 10 Jul, 2007 - 11:47 AM
Post #1


New D.I.C Head

*
Joined: 10 Jul, 2007
Posts: 2


My Contributions


I am trying to set up a "Recent Uploads" script for the images that get uploaded to my site, but keep hitting a snag. Is it possible to have the image path just point at the folder where the images get uploaded to, instead of specifying an image to use?

Sorry if this isn't making sense...it's way beyond my knowledge level! An example of what I am looking to do can be found at tinypic [dot] com. They have the "Recent Videos" script that refreshes with the most recent uploads.

If needed, here is the code for my site so far.

CODE
<?
include "config.php";
?>
<html>
<head>
<title>XS GfX - Image Hosting for XS</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel='shortcut icon' href='favicon.ico'>
<style type="text/css">
<!--
.style2 {
    font-size: x-small;
    color: #666666;
}
.style3 {color: #FFFFFF}
.style4 {color: #E1E0D8}
.style10 {
    font-size: 10px;
    color: #000000;
}
-->
</style>
</head>
<center>
<body bgcolor='#272f80' background='background.gif'>
<br>
<table align='center' border='0' cellpadding='2' cellspacing='2' width='740' bgcolor='222222'>
<tr><td>
<link rel="stylesheet" href="style.css" type="text/css">
<img src="logo_up.png" height="125" width="740" border="0" alt=" ">
<center>
<br>
<br>
<br><br><br>

<?php
$logfile= '/var/www/html/Log.txt';
$IP = $_SERVER['REMOTE_ADDR'];
$logdetails=  date("F j, Y, g:i a") . ': ' . '<a href=http://dnsstuff.com/tools/city.ch?ip='.$_SERVER['REMOTE_ADDR'].'>'.$_SERVER['REMOTE_ADDR'].'</a>';
$fp = fopen($logfile, "a");
fwrite($fp, $logdetails);
fwrite($fp, "<br>");
fclose($fp);
?>

<?
$divd = 1025;
$isize = $max_size / $divd;
$isize2 = round($isize);
?>

<span class="style3">Select an image to upload<br>
Max file size is set at</span> <?echo $isize2;?> <span class="style4">KB</span><br>
<br>
<form method="post" enctype="multipart/form-data" action="basic.php">
<INPUT TYPE="file" NAME="userfile" size="27">
<br><br><br>
<input type="submit" value="Upload" name="upload">
</form>
<p class="style10">Vulgar or Explicit content is not allowed!</p>
</td></tr>
<tr>
  <td><p>  <a href="http://www.xtreme-source.com"><img src="xs.gif" alt="XS" width="88" height="31" border="0"></a> <img src="greybar.gif" alt="Grey" width="560" height="33"><a href="http://www.xtreme-source.com/tutorials-adobe-photoshop/"><img src="gfxtutorials.gif" alt="GfX Tuts" width="88" height="31" border="0"></a></p></td>
</tr>
</table>

<?
//chooses a random number
$num = Rand (0,11);

//starts the random quote switch loop
switch ($num)
{
case 0:
echo "No soup for you!";
break;

case 1:
echo "Human Contact is overrated...";
break;

case 2:
echo "If you can't laugh at yourself, make fun of other people!";
break;

case 3:
echo "Confucius says BFD!";
break;

case 4:
echo "
It takes 46 muscles to frown but only 4 to flip 'em the bird. ";
break;

case 5:
echo "Behind every successful man is a surprised woman.";
break;

case 6:
echo "A bartender is just a pharmacist with a limited inventory.";
break;

case 7:
echo "Assassins do it from behind.";
break;

case 8:
echo "Beauty is in the eye of the beer holder.";
break;

case 9:
echo "C program run. C program crash. C programmer quit.";
break;

case 10:
echo "Double your drive space. Delete Windows!";
break;

case 11:
echo "Error, no keyboard. Press F1 to continue.";
break;
}
?>


Appreciate any help!! biggrin.gif

This post has been edited by Jamaal10: 10 Jul, 2007 - 11:48 AM
User is offlineProfile CardPM

Go to the top of the page

snoj
post 10 Jul, 2007 - 12:23 PM
Post #2


$Null

Group Icon
Joined: 31 Mar, 2003
Posts: 3,304



Thanked 5 times

Dream Kudos: 700
My Contributions


Moved. Read the effing forum titles. mad.gif
User is offlineProfile CardPM

Go to the top of the page

Jamaal10
post 10 Jul, 2007 - 12:45 PM
Post #3


New D.I.C Head

*
Joined: 10 Jul, 2007
Posts: 2


My Contributions


QUOTE(hotsnoj @ 10 Jul, 2007 - 01:23 PM) *

Moved. Read the effing forum titles. mad.gif


Wow...great way to represent this place!

It was put in that section because all of the scripts that I've seen for random images are done in javascript.
User is offlineProfile CardPM

Go to the top of the page

snoj
post 10 Jul, 2007 - 01:29 PM
Post #4


$Null

Group Icon
Joined: 31 Mar, 2003
Posts: 3,304



Thanked 5 times

Dream Kudos: 700
My Contributions


And nice way to represent yourself by 1) posting in the wrong forum and 2) posting code that doesn't have a bit of code that pertains to what you are trying to accomplish. 3) You wanted to know about getting the last X number of images which is done on the server-side of things so javascript has nothing to do with it. 4) You never mentioned anything about random images or javascript in your initial post.

As for listing the most recent uploaded images. You read the directory they are saved to and then order those by creation date, which can me found using the filemtime() function even though it's for getting the time it was last modified. However theoretically you shouldn't be changing the files all that often so it would be rather reliable.

Alternatively you could log to a database (or some other medium) when the file was uploaded and work from that. I'd personally go with the database since it would be less intensive to get info from that than going though an entire directory of files (which will likely get very big over time).
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 06:27AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month