Forum Moderators: coopster
Here's the code for the script that's supposed to "upload the image and save path in the DB":
<?
include("config.php");
?>
<FORM ENCTYPE="multipart/form-data" ACTION="imageupload.php" METHOD="POST">
Choose the image: <INPUT TYPE="file" NAME="userfile"><br>
<INPUT TYPE="submit" VALUE="Upload">
</FORM>
<?php
$path = "../players/";
$max_size = 2000000;
//2 Mb, any bigger than that is overkill.
if (!isset($HTTP_POST_FILES['userfile'])) exit;
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
if ($HTTP_POST_FILES['userfile']['size']>$max_size) { echo "Rozmiar pliku jest ponad 2 Mb.<br>\n"; exit; }
if (($HTTP_POST_FILES['userfile']['type']=="image/gif") ¦¦ ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") ¦¦ ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")) {
if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { echo "Plik juz istnieje<br>\n"; exit; }
$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .
$HTTP_POST_FILES['userfile']['name']);
if (!$res) { echo "Ladowanie Nie Pomyslne<br>\n"; exit; } else { echo "Ladowanie Pomyslne<br>\n"; }
// following line is for testing purposes only
echo "File Name: ".$HTTP_POST_FILES['userfile']['name']."<br>\n";
} else { echo "Wrong file type<br>\n"; exit; }
}
if($Upload)
{//begin of if($Upload).
// Set global variables to easier names
$imgpath = $HTTP_POST_FILES['userfile']['name']
//run the query which adds the data gathered from the form into the database
$result = mysql_query("INSERT INTO recentimages (imgpath)
VALUES ('$imgpath')",$connect);
echo "<center><h2>Path added successfully into database.</h2></center>"
}//end of else
?>
However, Im getting
an unexpected T_STRING on line 21, and unexpected T_VARIABLE on line 48, can anyone please help?
21: if (($HTTP_POST_FILES['userfile']['type']=="image/gif") ¦¦ ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") ¦¦ ($HTTP_POST_FILES['userfile']
48: $result = mysql_query("INSERT INTO recentimages (imgpath)