Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-16-2011, 05:22 PM   PM User | #1
Xaqa
Regular Coder

 
Join Date: May 2011
Posts: 118
Thanks: 23
Thanked 0 Times in 0 Posts
Xaqa is an unknown quantity at this point
Parse error: syntax error, unexpected T_STRING

First, here's my php code: (I put an arrow in line 164)

PHP Code:
<?php
if ((($_FILES["file"]["type"] == "image/jpg")
|| (
$_FILES["file"]["type"] == "image/pjpeg")
|| (
$_FILES["file"]["type"] == "image/png"))
&& (
$_FILES["file"]["size"] < 20000))
  {
  if (
$_FILES["file"]["error"] > 0)
    {
    echo 
"Return Code: " $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo 
"Upload: " $_FILES["file"]["name"] . "<br />";
    echo 
"Type: " $_FILES["file"]["type"] . "<br />";
    echo 
"Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo 
"Temp file: " $_FILES["file"]["tmp_name"] . "<br />";

    if (
file_exists("uploads/" $_FILES["file"]["name"]))
      {
      
mkdir("uploads/1/" $_FILES["file"]["name"])
      
move_uploaded_file($_FILES["file"]["tmp_name"], <--- 164
      
"upload/1/" $_FILES["file"]["name"]);
      echo 
"Stored in: " "upload/1/" $_FILES["file"]["name"];
      }
    else
      {
      
move_uploaded_file($_FILES["file"]["tmp_name"],
      
"upload/" $_FILES["file"]["name"]);
      echo 
"Stored in: " "upload/" $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo 
"Please select a file to upload";
  }
?>
The Error: Parse error: syntax error, unexpected T_STRING in /hermes/bosweb/web258/b2582/ipg.crowngaming/files/private/index.php on line 164

Last edited by Xaqa; 06-16-2011 at 08:53 PM..
Xaqa is offline   Reply With Quote
Old 06-16-2011, 05:25 PM   PM User | #2
redixx
New Coder

 
Join Date: Jun 2011
Posts: 56
Thanks: 0
Thanked 17 Times in 17 Posts
redixx is an unknown quantity at this point
You missed a semi-colon on the line above it.

mkdir("uploads/1/" . $_FILES["file"]["name"]);
redixx is offline   Reply With Quote
Users who have thanked redixx for this post:
Xaqa (06-16-2011)
Old 06-16-2011, 05:34 PM   PM User | #3
Xaqa
Regular Coder

 
Join Date: May 2011
Posts: 118
Thanks: 23
Thanked 0 Times in 0 Posts
Xaqa is an unknown quantity at this point
Thanks. Silly me.
Xaqa is offline   Reply With Quote
Old 06-16-2011, 05:52 PM   PM User | #4
Xaqa
Regular Coder

 
Join Date: May 2011
Posts: 118
Thanks: 23
Thanked 0 Times in 0 Posts
Xaqa is an unknown quantity at this point
Now I get this error:

Warning: move_uploaded_file(uploads/1/ad.png) [function.move-uploaded-file]: failed to open stream: Is a directory in /hermes/bosweb/web258/b2582/ipg.crowngaming/files/private/index.php on line 166

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpkw0Jn8' to 'uploads/1/ad.png' in /hermes/bosweb/web258/b2582/ipg.crowngaming/files/private/index.php on line 166
Stored in: uploads/1/ad.png
Xaqa is offline   Reply With Quote
Old 06-16-2011, 05:55 PM   PM User | #5
redixx
New Coder

 
Join Date: Jun 2011
Posts: 56
Thanks: 0
Thanked 17 Times in 17 Posts
redixx is an unknown quantity at this point
Because you just created a directory called $_FILES['file']['name'], and then you try to move your temp file to that folder. You would need something like this instead:

Code:
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/1/" . $_FILES["file"]["name"] . "/" . $_FILES["file"]["name"]);
redixx is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:26 AM.


Advertisement
Log in to turn off these ads.