Jump to content

PHP CODE ERROR BASIC, NOOB, HELP

Go to solution Solved by L.E.D,
if (isset($_GET['file']) && basename($_GET)['file'])==$_GET['file']){
{

I think you have 1 too many parenthesis in there, after $_GET.

 

if (isset($_GET['file']) && basename($_GET['file'])==$_GET['file']){
}

 

 

Can anyone figure out what is wrong with my code i keep getting this error  (Parse error: syntax error, unexpected '==' (T_IS_EQUAL) in C:\xampp\htdocs\tutorial\index.php on line 5)

basically something is wrong here if (isset($_GET['file']) && basename($_GET)['file'])==$_GET['file']){

I cant figure it out. I'm a noob in training

 

 

<?php
//localhost/tutorial/index.php
//in htdocs you have a folder named downloads and the index.php outside//

if (isset($_GET['file']) && basename($_GET)['file'])==$_GET['file']){

 $filename = $_GET['file'];
 //downloads is a folder in htdocs
$path = 'downloads/'.$filename;

 if (file_exists($path) && is_readable($path)){
     $size = filesize($path);
     header('Content-Type: application/octet-stream');
     header('Content-Length: '.$size);
     header('Content-Disposition: attachment; filename='.$filename);
     header('Content-Transfer-Encoding: binary');

     //open the file in binary read-only mode
     $file= @ fopen($path, 'rb');
     if ($file) {
         //stream the file and exist
         fpassthru($file);
         exit;
  }
 }
}
?>
<!DOCTYPE html>
<html>
<head>
    <title>PHP Download File TUtorial</title>
</head>
<body>
<!--index1.php was replaced with index.php by accident-->
<!--randomapp is the file and .zip can be .rar-->
<a href="index.php?file=code.7z">Download File</a>
    <!--you can add more <a href="index1.php?file=randomapp.zip">Download File</a> -->
</body>
</html>

Link to comment
https://linustechtips.com/topic/683454-php-code-error-basic-noob-help/
Share on other sites

Link to post
Share on other sites

if (isset($_GET['file']) && basename($_GET)['file'])==$_GET['file']){
{

I think you have 1 too many parenthesis in there, after $_GET.

 

if (isset($_GET['file']) && basename($_GET['file'])==$_GET['file']){
}

 

There are 10 types of people in the world: Those who understand binary, and those who don't.

Just some helpful stuff: You're - You are, Your - Your car, They're - They are, Their - Their car, There - Over there.

 

Folding @ Home Install Guide and Links | My Build

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×