Jump to content


Photo

What is the problem here?


  • Please log in to reply
2 replies to this topic

#1 wasper-rocker

wasper-rocker
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 July 2006 - 06:59 AM

I am running this script to get a file uploaded to a directory on my server but it just comes up with this error.

<?php 


$target = "www.wasper-rocker.co.uk/Protected/uploaded/"; 


$target = $target . basename( $_FILES['uploaded']['name']);
if ($uploaded_size > 250000)
{
echo "Your file is too large.<br>"; 
$ok=0;
}  
if (!($uploaded_type=="image/gif"))  {
if (!($uploaded_type=="image/jpeg")) {
echo "You may only upload Image files.<br>";
$ok=0;
} 
}

if ($ok==0) 
{ 
Echo "Sorry your file was not uploaded"; 
} 

if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";



$con = mysql_connect("localhost","i04wasp_duncan","WASP5rock");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("i04wasp_", $con);

$sql="INSERT INTO account
(picname)
VALUES
('$_POST[nickname]$_FILES['uploadedfile']['name'])} 
else {
echo "Sorry, there was a problem uploading your file.";
}



?>

Error: "Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/i04wasp/public_html/uploaded.php on line 42"

#2 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 06 July 2006 - 07:26 AM

I have modify abit of your code,
<?php


$target = "www.wasper-rocker.co.uk/Protected/uploaded/";


$target = $target . basename( $_FILES['uploaded']['name']);
if ($uploaded_size > 250000)
{
echo "Your file is too large.<br>";
$ok=0;
}
if (!($uploaded_type=="image/gif"))  {
if (!($uploaded_type=="image/jpeg")) {
echo "You may only upload Image files.<br>";
$ok=0;
}
}

if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}

if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}

$con = mysql_connect("localhost","i04wasp_duncan","WASP5rock") or die('Could not connect: ' . mysql_error());
mysql_select_db("i04wasp_", $con) or die('Sorry, there was a problem connecting to database.');

mysql_query("INSERT INTO `account` VALUES ('".$_POST[nickname]."', '".$_FILES['uploadedfile']['name']."')") or die ('Sorry, there was a problem uploading your file.');

?>

You need to modify to fit your code, because I'm not sure your database table structure.

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#3 wasper-rocker

wasper-rocker
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 July 2006 - 03:49 PM

Now This error comes up:

"Sorry your file was not uploaded
Warning: move_uploaded_file(www.wasper-rocker.co.uk/Protected/uploaded/henry-head.gif): failed to open stream: No such file or directory in /home/i04wasp/public_html/uploaded.php on line 27

Warning: move_uploaded_file(): Unable to move '/tmp/php8u813W' to 'www.wasper-rocker.co.uk/Protected/uploaded/henry-head.gif' in /home/i04wasp/public_html/uploaded.php on line 27
Sorry, there was a problem uploading your file."

Even though the file does exist. Also i can only upload .gif files




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users