Jump to content

Uploading Error


elementz

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
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.