Jump to content

Recommended Posts

Hi, Jus making an Upload Script And trying to have it display the Link to the file for download.

 

Form Code:

<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="5242880" />
File:<input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

 

 

Upload Code(PHP):

<?php
$target_path = "uploads/";

$_FILES['uploadedfile']['tmp_name'];  

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

$filelink = str_replace(" ","%20",basename( $_FILES['uploadedfile']['name']));

$file = $_FILES['uploadedfile']['name'];

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). " has been uploaded";
?>
<br />
<?php
    echo "Your Link: <a href=71.76.24.184/uploads/" $filelink ">" $file "</a>";}
    else{
    echo "There was an error uploading the file, please try again!";
}
?>

 

PHP Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\Inetpub\public_html\uploader.php on line 17

 

Line 17=

echo "Your Link: <a href=71.76.24.184/uploads/" $filelink ">" $file "</a>";}

 

Sorry If I'm posting wrong I'm new to the Board and Coding from Scratch in PHP :)

Link to comment
https://forums.phpfreaks.com/topic/54690-unexpect-t_variable/
Share on other sites

You where missing quite a fewe concatination operators on that line. Ive also formatted it to make it a little easier to read.

 

<?php

  $target_path = "uploads/";
  $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
  $filelink = str_replace(" ","%20",basename( $_FILES['uploadedfile']['name']));
  $file = $_FILES['uploadedfile']['name'];

  if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). " has been uploaded<br />";
    echo "Your Link: <a href='71.76.24.184/uploads/" . $filelink . "'>" . $file . "</a>";
  } else {
    echo "There was an error uploading the file, please try again!";
  }

?>

Link to comment
https://forums.phpfreaks.com/topic/54690-unexpect-t_variable/#findComment-270456
Share on other sites

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.