Jump to content

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