Jump to content

Recommended Posts

Hello

 

I am trying to get the following script to work for uploading images to my websites images folder but keep getting the following error.

 

Parse error: syntax error, unexpected T_VARIABLE in /home/a9865238/public_html/uploads/upload.php on line 3

 

===============================================================================================

upload.html

===============================================================================================

 

<form action="upload.php" method="post" enctype="multipart/form-data">
File: <input type="file" name="filename" />
<input type="submit" value="Upload" />
</form>

 

===============================================================================================

upload.php

===============================================================================================

<?php

$folder = “/home/a9865238/public_html/images/”;
if (is_uploaded_file($HTTP_POST_$FILES['filename']['tmp_name']))  {   
    if (move_uploaded_file($HTTP_POST_$FILES['filename']['tmp_name'], $folder.$HTTP_POST_FILES['filename']['name'])) {
         Echo “File uploaded”;
    } else {
         Echo “File not moved to destination folder. Check permissions”;
    };
} else {
     Echo “File is not uploaded.”;
$name=$_FILES['file']["name"];
$path=$_FILES['file']["tmp_name"];
$destination="upload/".$name;
 
move_uploaded_file($path,$destination)?"file moved":"file not moved";
}; 
?>
 
 
Regards
Ant
Link to comment
https://forums.phpfreaks.com/topic/284119-image-upload-script-issue/
Share on other sites

You are using fancy quotes

 

$folder = “/home/a9865238/public_html/images/”;

 

Change the quotes

$folder = "/home/a9865238/public_html/images/";

You have to pay attention to the correct quotes when copying code from websites.

Edited by QuickOldCar

There was more, also you don't need a semicolon after the curly braces.

 

 

<?php
$folder = "/home/a9865238/public_html/images/";
if (is_uploaded_file($HTTP_POST_$FILES['filename']['tmp_name']))  {   
    if (move_uploaded_file($HTTP_POST_$FILES['filename']['tmp_name'], $folder.$HTTP_POST_FILES['filename']['name'])) {
         Echo "File uploaded";
    } else {
         Echo "File not moved to destination folder. Check permissions";
    }
} else {
     Echo "File is not uploaded.";
$name=$_FILES['file']["name"];
$path=$_FILES['file']["tmp_name"];
$destination="upload/".$name;
 
move_uploaded_file($path,$destination)?"file moved":"file not moved";
}
?>
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.