Jump to content


Photo

Uploading Error


  • Please log in to reply
1 reply to this topic

#1 elementz

elementz
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 03 April 2006 - 10:29 AM

Here are the files:

index.html
<html>
<head>
<title>Worlds Hosting Image Uploader</title>
</head>

<body>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form action="upload.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td><strong>Image Upload</strong></td>
</tr>
<tr>
<td>Select Image 
<input name="ufile" type="file" id="ufile" size="50" /></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Upload" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</body>
</html>


upload.php
<html>
<head>
<title>Worlds Hosting Image Uploader</title>
</head>
<body>

<?php

$valid = array (".png",".jpg",".gif",".bmp");


$filename = $HTTP_POST_FILES['ufile']['name'];

$type = strtolower(strstr($filename, '.'));
if (!in_array($type, $valid)) {
echo ("The submitted file was of invalid type.<br />");
}

 
$random_digit=rand(00000000,99999999);



$new_file_name=$random_digit.$filename;


$path= "upload/".$new_file_name;
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "Successful<BR/>"; 

$homeurl='http://www.worlds-hosting.com/image/upload/'

$url=$homeurl.$new_file_name;

}
else
{
echo "Error";
}
}
?>

<img src="<? echo $url; ?>"><br><br>
<a href="<? echo $url; ?>"><? echo $url; ?></a><br>
<?php
echo "File Size: ".$HTTP_POST_FILES['ufile']['size']."<BR />"; 
echo "File Type: ".$HTTP_POST_FILES['ufile']['type']."<BR/>"; 
?>


</body>
</html>


But when I try to run it, it gets the following error:

Parse error: parse error, unexpected T_VARIABLE in /home/worldsh/public_html/image/upload.php on line 36


Please help fix it.


Thankyou,
Luke

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 03 April 2006 - 01:34 PM

$homeurl='http://www.worlds-hosting.com/image/upload/'

$url=$homeurl.$new_file_name;

needs to be

$homeurl='http://www.worlds-hosting.com/image/upload/';

$url=$homeurl.$new_file_name;


You missed ; at the end :)

Regards
Liam
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users