Jump to content

What is the problem here?


wasper-rocker

Recommended Posts

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

[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");
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.";
}



?> [/code]

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"
Link to comment
https://forums.phpfreaks.com/topic/13818-what-is-the-problem-here/
Share on other sites

I have modify abit of your code,
[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.');

?>[/code]

You need to modify to fit your code, because I'm not sure your database table structure.
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

Archived

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

×
×
  • 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.