Jump to content

Archived

This topic is now archived and is closed to further replies.

elementz

Uploading Error

Recommended Posts

Here are the files:

[b]index.html[/b]
[code]<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>[/code]


[b]upload.php[/b]
[code]<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>[/code]


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

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


Please help fix it.


Thankyou,
Luke

Share this post


Link to post
Share on other sites
[code]$homeurl='http://www.worlds-hosting.com/image/upload/'

$url=$homeurl.$new_file_name;[/code]

needs to be

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

$url=$homeurl.$new_file_name;[/code]


You missed ; at the end :)

Regards
Liam

Share this post


Link to post
Share on other sites

×

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.