PDA

View Full Version : Problem!



Forge
13-02-2008, 10:33 AM
Hey as you might of guessed im making a free opensource image upload system. You may be thinking why is he having problems? Hes made one before!
This is using a different feature as when an image is uploaded it is named using time(); (so that images with the same name can be uploaded)

The image uploads fine but in the imagesource and the given link shows the name to the file twice.

e.g.
Filename

1234

Given link

12341234

Any ideas on how to fix this?

upload.php code

<?php

$iuspath = "http://www.devode.zzl.org/php/IUS/";
$image = $_FILES['image']['name'];
$imagesize = $_FILES['image']['size'];
$imagetype = $_FILES['image']['type'];
$urlextension = time();

$image = $urlextension;
$uploadpath = "uploads/". $image;

if ($imagesize<2048 && ereg("image", $imagetype))
{ move_uploaded_file($_FILES['image']['tmp_name'], $uploadpath);}

$folderlocation = $iuspath. $uploadpath;
$imagelocation = $folderlocation. $image;

echo("
<html>

<head>
<title>IUS | $image</title>
<link rel='stylesheet' href='css/default.css' />
</head>

<body>
<center>
<div id='container'>

<div id='logo'></div>

<div id='boxtop'></div>

<div id='boxmid'>
<a href='$imagelocation' target='_blank'>
<img src='$imagelocation' style='border: 1px solid #000000; width: 75px; height: 75px;'>
</a><br />
Click image to enlarge<br /><br />

Direct link: <input type='text' name='directlink' value='$imagelocation' size='50' />
</div>

<div id='boxbtm'></div>
</div>
</center>
</body>

</html>
");
?>

Thanks
- Luke

Awfy
13-02-2008, 11:05 AM
Why not just make the images have random codes like...

ia8bw9d7a.png

Something like that?

Johno
13-02-2008, 11:11 AM
If you do filenames, whats going to happen if two people upload a file called "Untitled"

I agree with Greg, it should be just a random code/url.

.:; Johno

Forge
13-02-2008, 11:26 AM
read it properly. It isnt set as filenames its set as time();
so each upload has been given a unique name

Bojangles
13-02-2008, 11:54 AM
Just randomise the images like tinypic etc.
No point in numbers :)

theJOSH
13-02-2008, 12:01 PM
Just randomise the images like tinypic etc.
No point in numbers :)


Read what he just said, you spoon.

Want to hide these adverts? Register an account for free!