PDA

View Full Version : could anyone give me a php script that changes the uploaded file to a number?


Adam_C
11-18-2009, 09:40 PM
(title)

i.e a file called 'picture.jpg' when uploaded is renamed to '1.jpg' then 'pic2.jpg' is renamed to '2.jpg' etc.

also the script must rename a file with a different extension to the next number,

i.e. (from above) 'photo.gif' is renamed to '3.gif' not started back to the first number.

i know it might be a lot but it would save a lot of time :)

thanks :D

edbr
11-19-2009, 12:37 AM
dont have one as now but if you right one then you would have to check final upload destination folder split the file name and extension, find the highest number then increment. i++, bit of work though. but a good training project i would say

tux
11-19-2009, 06:03 AM
Not got a script like that to hand and am off to sunnier climes for a week.

You could maybe get the table ID/Auto increment from your DB and add 1 to it then use that to rename the file.

Not tried it myself but you could use this......

rename($oldName, $targetName)

Also, you may want to check the file has not already been used in the folder. PHP has a function for this......

file_exists($targetpath)

Try the PHP manual for more info here....

http://www.php.net/manual/en/index.php

I try to help more when I get back if you havn't sorted it. Good luck.

Paul

Adam_C
11-19-2009, 03:57 PM
Not got a script like that to hand and am off to sunnier climes for a week.

You could maybe get the table ID/Auto increment from your DB and add 1 to it then use that to rename the file.

Not tried it myself but you could use this......

rename($oldName, $targetName)

Also, you may want to check the file has not already been used in the folder. PHP has a function for this......

file_exists($targetpath)

Try the PHP manual for more info here....

http://www.php.net/manual/en/index.php

I try to help more when I get back if you havn't sorted it. Good luck.

Paul

thanks :D it sounds obvious after reading both replies, and thats the reason why im making these scripts, i am only 16, but am learning php and others for later on in life,

thanks again, Adam.
:D

tux
11-19-2009, 05:42 PM
Very wise of you Adam. I wish I started to learn PHP when I was younger. I have only been learning for a couple of years on and off but have learnt such a lot, most of which has come from the guys here at DWC.

I appreciate the help I have received here and try to pass on what I have learnt to others when I can.

Good luck.

Adam_C
11-19-2009, 06:27 PM
Very wise of you Adam. I wish I started to learn PHP when I was younger. I have only been learning for a couple of years on and off but have learnt such a lot, most of which has come from the guys here at DWC.

I appreciate the help I have received here and try to pass on what I have learnt to others when I can.

Good luck.

thanks! and same, this site has been very helpful :)

Adam_C
11-19-2009, 07:30 PM
Not got a script like that to hand and am off to sunnier climes for a week.

You could maybe get the table ID/Auto increment from your DB and add 1 to it then use that to rename the file.

Not tried it myself but you could use this......

rename($oldName, $targetName)

Also, you may want to check the file has not already been used in the folder. PHP has a function for this......

file_exists($targetpath)

Try the PHP manual for more info here....

http://www.php.net/manual/en/index.php

I try to help more when I get back if you havn't sorted it. Good luck.

Paul

having problems with this script :( cant figure out how to add the extension back onto the file

Adam_C
11-19-2009, 07:31 PM
this is my complete form:

<?php
////////////////////////////////////// connection script - enter your details here
$database="portfolio";
$con = mysql_connect("localhost", "root", "password") or die(mysql_error());?>
<script type="text/javascript">alert("Connected to MySQL")</script>
<?php
mysql_select_db("portfolio") or die(mysql_error());?>
<script type="text/javascript">alert("Connected to Database")</script>
<?php
///////////////////////////////////////error handling - if an error is detected in the url the appropriate error will be displayed
$error = $_GET['error'];
if($error == 1){
$error = "Unknown Image extension!";
}elseif($error == 2){
$error = "You have exceeded the size limit";
}else $error = '';

function getExtension($str) {// function to get file extension

$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
// define max file size, change to suit your own maximum file size
define ("MAX_SIZE","1000");
$errors=0;
//get the original file from form
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$image = $_FILES["file"]["name"];// from your upload form
$uploadedfile = $_FILES['file']['tmp_name'];// from your upload form
// check for correct file extension
if ($image)
{
$filename = stripslashes($_FILES['file']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{

header("location:upload.php?error=1");// error handling here - if the file ext is wrong the script will exit and redirect with error in the url
exit;///////////////////////////////// note that I have used adam.php as the file name, change this if you save the file differently
}
// check for correct file size
else
{
$size=filesize($_FILES['file']['tmp_name']);

if ($size > MAX_SIZE*1024)
{

header("location:upload.php?error=2");// error handling here - if the file size is wrong the script will exit and redirect with error in the url
exit;///////////////////////////////// note that I have used adam.php as the file name, change this if you save the file differently
}
// check which extension we have and create file
if($extension=="jpg" || $extension=="jpeg" )
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension=="png")
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
}
else
{
$src = imagecreatefromgif($uploadedfile);
}
//declare destinations
$filename = "uploads/". $_FILES['file']['name'];
//write files to folders
imagejpeg($src,$filename,100);
//destroy temps to save memory
imagedestroy($src);
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Adam Carter | Portfolio</title>
<link href="main.css" type="text/css" media="screen" rel="stylesheet"/>
<link href="styles.css" type="text/css" media="screen" rel="stylesheet" />
<link href="upload.css" type="text/css" media="screen" rel="stylesheet" />
<script type="text/javascript" src="mootools/mootools.js"></script>
<script type="text/javascript" src="mootools/mooefx.js"></script>
<link href="mootools/menu.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<div id="header"></div>
<div id="content">
<div id="sidebar">
<ul>
<li class="home"><a href="index.php" >Home</a></li>
<li class="about"><a href="about.php" >About</a></li>
<li class="portfolio"><a href="portfolio.php" >Portfolio</a></li>
<li class="contact"><a href="contact.php" >Contact</a></li>
<li><a href="upload.php">Upload</a></li>
</ul>
</div>
<div id="maincontent">
<h3 class="mainheader">Upload</h3>
<br />
<br />
<br />
<div id="uploadholder"> <?php echo $success; ?><?php echo $error; ?>
<form name="upload" enctype="multipart/form-data" action="<?php $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="1048576" />
<!--10MB-->
<h3 class="uploadhead">Enter file information: </h3>
<div class="linebreak"></div>
<br />
<input class="space" name="name" maxlength="20" style="width:250px;" type="text" alt="Name" value="Name (20 Char Max)" onClick="this.value=''" onBlur="if (this.value==''){this.value='name'}" />
<br />
<input class="space" name="shortinfo" maxlength="30" style="width:250px;" type="text" alt="Short Info" value="Short Info (30 Char Max)" onClick="this.value=''" onBlur="if (this.value==''){this.value='Short Info'}"/>
<br />
<input class="space" name="longinfo" maxlength="100" style="width:250px;" type="text" alt="Long Info" value="Long Info (100 Char Max)" onClick="this.value=''" onBlur="if (this.value==''){this.value='Long Info'}"/>
<br />
<input class="space" name="file" type="file" title="Upload Large File" value="Upload Large File"/>
<br />
<br />
<input class="space" type="submit" name="Submit" id="Submit" value="Upload File" />
</form>
<?php
//Get number of files in the db
$renamesql = mysql_query("SHOW TABLES")or die(mysql_error());

while($fetch = mysql_fetch_array($renamesql)){
$renamesql2 = mysql_query("SELECT * FROM `logos` ORDER BY id DESC LIMIT 1")or die(mysql_error());

while($row = mysql_fetch_array($renamesql2)){
$newfilenamewithoutext=$row['id'];
echo "<span>". $newfilename. "</span>";
}
}

//Rename ild file to number
$newfilename=$newfilenamewithoutext+".jpg";
$oldestfilename= $_FILES['file']['name'];
$oldfilename = substr($oldestfilename, 0, strrpos($oldestfilename, '.'));
rename($oldestfilename, $newfilename);
//If no errors registered, insert file name into database and print the success message
$name= $_POST['name'];
$shortinfo= $_POST['shortinfo'];
$longinfo= $_POST['longinfo'];

if(isset($_POST['Submit']) && !$errors)
{
mysql_query("INSERT INTO `portfolio`.`logos` (`id`, `name`, `timestamp`, `shortinfo`, `longinfo`, `content`) VALUES (NULL, '$name', CURRENT_TIMESTAMP, '$shortinfo', '$longinfo', '$image')");

$success = "Image Uploaded Successfully!";
}
//////////////////////////////////////////////////select file names from database
$query = sprintf("SELECT * FROM logos ");
$result = @mysql_query($query);
$row = @mysql_fetch_array($result);
?>
</div>
</div>
</div>
</div>
</body>
</html>

line 144 is where it goes wrong, could you look over my script and add in the rename file part as i have no idea what to do next,

thanks :D

Adam_C
11-21-2009, 02:16 PM
<?php
////////////////////////////////////// connection script - enter your details here
$database="portfolio";
$con = mysql_connect("localhost", "user", "pword") or die(mysql_error());?>
<script type="text/javascript">alert("Connected to MySQL")</script>
<?php
mysql_select_db("portfolio") or die(mysql_error());?>
<script type="text/javascript">alert("Connected to Database")</script>
<?php
///////////////////////////////////////error handling - if an error is detected in the url the appropriate error will be displayed
$error = $_GET['error'];
if($error == 1){
$error = "Unknown Image extension!";
}elseif($error == 2){
$error = "You have exceeded the size limit";
}else $error = '';

function getExtension($str) {// function to get file extension

$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
// define max file size, change to suit your own maximum file size
define ("MAX_SIZE","1000");
$errors=0;
//get the original file from form
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$image = $_FILES["file"]["name"];// from your upload form
$uploadedfile = $_FILES['file']['tmp_name'];// from your upload form
// check for correct file extension
if ($image)
{
$filename = stripslashes($_FILES['file']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{

header("location:upload.php?error=1");// error handling here - if the file ext is wrong the script will exit and redirect with error in the url
exit;///////////////////////////////// note that I have used adam.php as the file name, change this if you save the file differently
}
// check for correct file size
else
{
$size=filesize($_FILES['file']['tmp_name']);

if ($size > MAX_SIZE*1024)
{

header("location:upload.php?error=2");// error handling here - if the file size is wrong the script will exit and redirect with error in the url
exit;///////////////////////////////// note that I have used adam.php as the file name, change this if you save the file differently
}
// check which extension we have and create file
if($extension=="jpg" || $extension=="jpeg" )
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension=="png")
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
}
else
{
$src = imagecreatefromgif($uploadedfile);
}
//declare destinations
$filename = "uploads/". $_FILES['file']['name'];
//write files to folders
imagejpeg($src,$filename,100);
//destroy temps to save memory
imagedestroy($src);
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Adam Carter | Portfolio</title>
<link href="main.css" type="text/css" media="screen" rel="stylesheet"/>
<link href="styles.css" type="text/css" media="screen" rel="stylesheet" />
<link href="upload.css" type="text/css" media="screen" rel="stylesheet" />
<script type="text/javascript" src="mootools/mootools.js"></script>
<script type="text/javascript" src="mootools/mooefx.js"></script>
<link href="mootools/menu.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<div id="header"></div>
<div id="content">
<div id="sidebar">
<ul>
<li class="home"><a href="index.php" >Home</a></li>
<li class="about"><a href="about.php" >About</a></li>
<li class="portfolio"><a href="portfolio.php" >Portfolio</a></li>
<li class="contact"><a href="contact.php" >Contact</a></li>
<li><a href="upload.php">Upload</a></li>
</ul>
</div>
<div id="maincontent">
<h3 class="mainheader">Upload</h3>
<br />
<br />
<br />
<div id="uploadholder"> <?php echo $success; ?><?php echo $error; ?>
<form name="upload" enctype="multipart/form-data" action="<?php $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="1048576" />
<!--10MB-->
<h3 class="uploadhead">Enter file information: </h3>
<div class="linebreak"></div>
<br />
<span class="space">Main File: &nbsp;
<input name="file" type="file" title="Upload Large File" value="Upload Large File"/></span>
<br />
<span class="space">File Name: &nbsp;
<input name="name" maxlength="20" style="width:250px;" type="text" alt="Name" value=" (20 Char Max)" onClick="if (this.value=' (20 Char Max)') { this.value=''}" /></span>
<br />
<span class="space">Short Info: &nbsp;
<input name="shortinfo" maxlength="30" style="width:250px;" type="text" alt="Short Info" value=" (30 Char Max)" onClick="if (this.value=' (30 Char Max)') { this.value=''}" /></span>
<br />
<span class="space">Long Info: &nbsp;
<input name="longinfo" maxlength="100" style="width:250px;" type="text" alt="Long Info" value=" (100 Char Max)" onclick="if (this.value=' (100 Char Max)') { this.value=''}" /></span>
<br />
<br />
<br />
<input type="submit" name="Submit" id="Submit" value="Upload File" />
</form>
<?php
//Get number of files in the db
$renamesql = mysql_query("SHOW TABLES")or die(mysql_error());

while($fetch = mysql_fetch_array($renamesql)){
$renamesql2 = mysql_query("SELECT * FROM `logos` ORDER BY `logos`.`id` DESC LIMIT 1")or die(mysql_error());

while($row = mysql_fetch_array($renamesql2)){
$newfilenamewithoutext=$row['id'];
}
}

//Rename ild file to number
$filenameold= $_FILES['file']['name'];
$oldestfilename= $_FILES['file']['tmp_name'];
$newfilename=$newfilenamewithoutext. ".". $extension;
$oldfilename = substr($filenameold, 0, strrpos($oldestfilename, '.'));
rename($oldfilename, $newfilename) or die(mysql_error());
//If no errors registered, insert file name into database and print the success message
$name= $_POST['name'];
$shortinfo= $_POST['shortinfo'];
$longinfo= $_POST['longinfo'];

if(isset($_POST['Submit']) && !$errors)
{
mysql_query("INSERT INTO `portfolio`.`logos` (`id`, `name`, `timestamp`, `shortinfo`, `longinfo`, `file`) VALUES (NULL, '$name', CURRENT_TIMESTAMP, '$shortinfo', '$longinfo', '$image')");

$success = "Image Uploaded Successfully!";
}
//////////////////////////////////////////////////select file names from database
$query = sprintf("SELECT * FROM logos ");
$result = @mysql_query($query);
$row = @mysql_fetch_array($result);
?>
</div>
</div>
</div>
</div>
</body>
</html>

Here is what i have so far, haven't got a clue what else to try and do?

please help. thanks :D

tux
11-29-2009, 03:32 PM
Hi Adam,

Try this, I didn't use the rename function as have changed the file name before it is written. Not fully tested this but give it a go.

<?php
////////////////////////////////////// connection script - enter your details here
$user="user";
$password="password";
$database="dbname";
$con = mysql_connect (localhost,$user,$password);
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("tablename", $con);
///////////////////////////////////////error handling - if an error is detected in the url the appropriate error will be displayed
$error = $_GET['error'];
if($error == 1){
$error = "Unknown Image extension!";
}elseif($error == 2){
$error = "You have exceeded the size limit";
}else $error = '';
//////////////////////////////////////upload/resize script

function getExtension($str) {// function to get file extension

$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
// define max file size, change to suit your own maximum file size
define ("MAX_SIZE","1000");
$errors=0;
//get the original file from form
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$image = $_FILES["file"]["name"];// from your upload form
$uploadedfile = $_FILES['file']['tmp_name'];// from your upload form
// check for correct file extension
if ($image)
{
$filename = stripslashes($_FILES['file']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{

header("location:adam.php?error=1");// error handling here - if the file ext is wrong the script will exit and redirect with error in the url
exit;///////////////////////////////// note that I have used adam.php as the file name, change this if you save the file differently
}
// check for correct file size
else
{
$size=filesize($_FILES['file']['tmp_name']);

if ($size > MAX_SIZE*1024)
{

header("location:adam.php?error=2");// error handling here - if the file size is wrong the script will exit and redirect with error in the url
exit;///////////////////////////////// note that I have used adam.php as the file name, change this if you save the file differently
}
// check which extension we have and create file
if($extension=="jpg" || $extension=="jpeg" )
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension=="png")
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
}
else
{
$src = imagecreatefromgif($uploadedfile);
}
//rename file and declare destinations
$query = sprintf("SELECT ID FROM logos ORDER BY ID DESC");
$result = @mysql_query($query);
$ID = @mysql_fetch_array($result);
$newfileNo = $ID['ID'] + 1;//query takes last table row ID and adds 1
$dot = ".";//the dot between the file number and the extension
$newfilename = $newfileNo . $dot . $extension;//new file name
$newfilepath = "uploads/" . $newfileNo . $dot . $extension;//new file path
//write files to folders
imagejpeg($src,$newfilepath,100);
//destroy temps to save memory
imagedestroy($src);
}
}
}
//If no errors registered, insert file name into database and print the success message
if(isset($_POST['Submit']) && !$errors)
{
/////////////////////////////////////get last file name using table auto increment ID


mysql_query("INSERT INTO logos (content) VALUES ('$newfilename')");//new value has been changed here

$success = "Image Uploaded Successfully!";
}
//////////////////////////////////////////////////select file names from database
$query = sprintf("SELECT * FROM logos ");
$result = @mysql_query($query);
$row = @mysql_fetch_array($result);


?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TITLE</title>
<!--LINKS TGO CSS AND JS-->
</head>
<body>
<p><?php echo $success; ?><?php echo $error; ?></p>
<form name="upload" enctype="multipart/form-data" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<input type="file" name="file" id="file" >
<input type="submit" name="Submit" id="Submit" value="Upload Image">
</form>

<?php if($success){ do{ ?>
<p><a href="uploads/<?php echo $row['content']; ?>">View File!</a></p>
<?php
}while($row = @mysql_fetch_array($result));
}
?>
</body>
</html>

Let me know how it goes.

Regards Paul

Adam_C
11-29-2009, 03:56 PM
Hi Adam,

Try this, I didn't use the rename function as have changed the file name before it is written. Not fully tested this but give it a go.

<?php
////////////////////////////////////// connection script - enter your details here
$user="user";
$password="password";
$database="dbname";
$con = mysql_connect (localhost,$user,$password);
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("tablename", $con);
///////////////////////////////////////error handling - if an error is detected in the url the appropriate error will be displayed
$error = $_GET['error'];
if($error == 1){
$error = "Unknown Image extension!";
}elseif($error == 2){
$error = "You have exceeded the size limit";
}else $error = '';
//////////////////////////////////////upload/resize script

function getExtension($str) {// function to get file extension

$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
// define max file size, change to suit your own maximum file size
define ("MAX_SIZE","1000");
$errors=0;
//get the original file from form
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$image = $_FILES["file"]["name"];// from your upload form
$uploadedfile = $_FILES['file']['tmp_name'];// from your upload form
// check for correct file extension
if ($image)
{
$filename = stripslashes($_FILES['file']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{

header("location:adam.php?error=1");// error handling here - if the file ext is wrong the script will exit and redirect with error in the url
exit;///////////////////////////////// note that I have used adam.php as the file name, change this if you save the file differently
}
// check for correct file size
else
{
$size=filesize($_FILES['file']['tmp_name']);

if ($size > MAX_SIZE*1024)
{

header("location:adam.php?error=2");// error handling here - if the file size is wrong the script will exit and redirect with error in the url
exit;///////////////////////////////// note that I have used adam.php as the file name, change this if you save the file differently
}
// check which extension we have and create file
if($extension=="jpg" || $extension=="jpeg" )
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension=="png")
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
}
else
{
$src = imagecreatefromgif($uploadedfile);
}
//rename file and declare destinations
$query = sprintf("SELECT ID FROM logos ORDER BY ID DESC");
$result = @mysql_query($query);
$ID = @mysql_fetch_array($result);
$newfileNo = $ID['ID'] + 1;//query takes last table row ID and adds 1
$dot = ".";//the dot between the file number and the extension
$newfilename = $newfileNo . $dot . $extension;//new file name
$newfilepath = "uploads/" . $newfileNo . $dot . $extension;//new file path
//write files to folders
imagejpeg($src,$newfilepath,100);
//destroy temps to save memory
imagedestroy($src);
}
}
}
//If no errors registered, insert file name into database and print the success message
if(isset($_POST['Submit']) && !$errors)
{
/////////////////////////////////////get last file name using table auto increment ID


mysql_query("INSERT INTO logos (content) VALUES ('$newfilename')");//new value has been changed here

$success = "Image Uploaded Successfully!";
}
//////////////////////////////////////////////////select file names from database
$query = sprintf("SELECT * FROM logos ");
$result = @mysql_query($query);
$row = @mysql_fetch_array($result);


?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TITLE</title>
<!--LINKS TGO CSS AND JS-->
</head>
<body>
<p><?php echo $success; ?><?php echo $error; ?></p>
<form name="upload" enctype="multipart/form-data" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<input type="file" name="file" id="file" >
<input type="submit" name="Submit" id="Submit" value="Upload Image">
</form>

<?php if($success){ do{ ?>
<p><a href="uploads/<?php echo $row['content']; ?>">View File!</a></p>
<?php
}while($row = @mysql_fetch_array($result));
}
?>
</body>
</html>

Let me know how it goes.

Regards Paul

thank you very much, but i forgot to close the forum :P

i done it the same day but forgot to update here :)

thanks for your help though, it is very much appreciated,

Adam.