Jump to content

Image upload script issue


aelouch

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.

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";
}
?>

Archived

This topic is now archived and is closed to further replies.

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