Getting an error: Parse error: syntax error, unexpected $end
Hi,
I'm trying to implement some php code that I have in one document into another document.
However when I do that I get this error:
Parse error: syntax error, unexpected $end in /home/www/wearecrunch.dk/gammelsjuf/ajax/class/phUploader.php on line 470
I think it has something to do with where I'm placing the code, but not sure?
// Function to get the extension a file.
function get_ext($key) {
$key=strtolower(substr(strrchr($key, "."), 1));
$key=str_replace("jpeg","jpg",$key);
return $key;
}
// Filename security cleaning. Do not modify.
function cln_file_name($string) {
$cln_filename_find=array("/\.[^\.]+$/", "/[^\d\w\s-]/", "/\s\s+/", "/[-]+/", "/[_]+/");
$cln_filename_repl=array("", ""," ", "-", "_");
$string=preg_replace($cln_filename_find, $cln_filename_repl, $string);
return trim($string);
}
// If a password is set, they must login to upload files.
If($password) {
//Verify the credentials.
If($_POST['verify_password']==true) {
If(md5($_POST['check_password'])==$password_hash) {
setcookie("phUploader",$password_hash);
sleep(1); //seems to help some people.
header("Location: http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
} // If Password
echo "2";
// Dont allow submit if $password_form has been populated
If(($_POST['submit']==true) AND ($password_form=="")) {
echo "3";
//Tally the size of all the files uploaded, check if it's over the ammount.
If(array_sum($_FILES['file']['size']) > $max_combined_size*5000) {
$error.="<b>FAILED:</b> All Files <b>REASON:</b> Combined file size is to large.<br />";
// Loop though, verify and upload files.
} Else {
echo "4";
// Loop through all the files.
For($i=0; $i <= $file_uploads-1; $i++) {
// If a file actually exists in this key
If($_FILES['file']['name'][$i]) {
echo "5";
//Get the file extension
$file_ext[$i]=get_ext($_FILES['file']['name'][$i]);
If(($error=="") AND ($success=="")) {
$error.="<b>FAILED:</b> No files selected<br />";
}
$display_message=$success.$error;
} // $_POST AND !$password_form
include_once( 'class/class.upload.php' );
if(isset($_POST['upload'])){
$filname=$_FILES['file_name'];
$handle = new upload($filname);
$handle->allowed = array('image/*');
if($handle->uploaded){
$handle->image_border = 5; // defining border width
$handle->image_border_color = '#000'; // defining border color
$handle->image_watermark = 'badge.png'; // watermark image src
$handle->image_watermark_position = 'BR'; // watermark image position again "B" for bottom and so on.
$handle->image_resize = true; // making resize function to true
$handle->image_x = 160; // making width to 160px
$handle->image_y = 160; // making hight to 160px
$handle->process('uploads/');
if ($handle->processed) {
It is the bottom part of the code that I have placed, so I think it is placed a wrong place.
Does anyone know where I should place it so I don't get the error.
what happens if you put the last lines of code , this :
// $_POST AND !$password_form
include_once( 'class/class.upload.php' );
if(isset($_POST['upload'])){
$filname=$_FILES['file_name'];
$handle = new upload($filname);
$handle->allowed = array('image/*');
if($handle->uploaded){
$handle->image_border = 5; // defining border width
$handle->image_border_color = '#000'; // defining border color
$handle->image_watermark = 'badge.png'; // watermark image src
$handle->image_watermark_position = 'BR'; // watermark image position again "B" for bottom and so on.
$handle->image_resize = true; // making resize function to true
$handle->image_x = 160; // making width to 160px
$handle->image_y = 160; // making hight to 160px
$handle->process('uploads/');
if ($handle->processed) {
at the beginning of the file?
generally include_once , includes in general are placed on top , also if( isset($_POST ) , not at the bottom
Bookmarks