Jump to content

Recommended Posts

I am now getting a similar parse error.

The below code worked once. Then I tried to add additional image/types to the upload script in the if statement and it failed. Even after removing new code.

 

Error:

Parse error: syntax error, unexpected '[', expecting ')' in C:\www\idea\imagebox\add_image.php on line 61

 

Line 61 Is first line in upload function:

 

function upload_image($_FILES['imagefile'],$image_to_thumbnail)

 

Full code:

<style type="text/css">
<!--
input
{
color: #000000;
background: #FFFFFF;
border: 1px solid #000000;
font-size: 10px;
font-family: Arial, Helvetica, sans-serif;
}

.input_images
{
vertical-align:middle;
color: #000000;
background: #FFFFFF;
border: 0px solid #FFFFFF;
font-size: 10px;
font-family: Arial, Helvetica, sans-serif;
}

-->
</style>

<form name="copyimage" method="post" action="copy.php" enctype="multipart/form-data">
<input name="action" type="hidden" value="copy" />
<input name="url" type="text" value="" size="100"><input name="filename" type="text" value="" size="20">
<input name="action" type="hidden" value="copy">
<input type="image" class="input_images" src="../images/add.png" alt="Add">
</form> 

<form name="uploadimage" method="post" action="upload.php" enctype="multipart/form-data">
<input name="imagefile" type="file" size="100">
<input name="Upload" type="submit" value="upload" />
</form>


<?php


$action = $HTTP_POST_VARS[action];

if ($action == "copy")
{
	copy_image( $file_name );
}

if ($action == "upload")
{
	upload_image( $imagefile );
}



?>

<?php

//upload image function

function upload_image($_FILES['imagefile'],$image_to_thumbnail)
{
ini_set('display_errors', 1);
error_reporting(E_ALL);

//$submit = $_POST['Submit'];
if (empty($_FILES['imagefile']))
	{
		echo "<br><br>";
		echo "Please choose a image to upload...";
		die;
	}


if(!empty( $_FILES['imagefile'] ))
{

	//If the Submitbutton was pressed do:

	if ($_FILES['imagefile']['type'] == "image/jpeg")
	{

		$_FILES['imagefile']['name'] = str_replace(" ", "_", $_FILES['imagefile']['name']);

		copy ($_FILES['imagefile']['tmp_name'], "images/full/".$_FILES['imagefile']['name']) or die ("Could not copy"); 

		echo "<br><br>"; 
        	
		echo "<b>File Uploaded...</b>"; 
        }

 	else 
 	{
            echo "<br><br>";
            //echo "Could Not Copy... (".$_FILES['imagefile']['name'].")<br>";
		echo "Could Not Copy... <br>";
		die;
     	}
}   

echo "<br>";
$image_to_thumbnail = $_FILES['imagefile']['name'];
//echo $image_to_thumbnail;

include "resize_image.php";

echo "image uploaded";
echo "<br>";
echo "<img src=images/thumbs/t_".$image_to_thumbnail." />";
echo "<br>";
echo "<img src=images/full/".$image_to_thumbnail." />";
}
?> 

<?php

//function to copy image
function copy_image($url, $file_name, $image_to_thumbnail)
{

	$url = $HTTP_POST_VARS[url];
	$file_name = $HTTP_POST_VARS[filename];


	if ($url == "")
	{
		echo "You must enter a url. ";
		echo "<meta http-equiv='REFRESH' content=3;url=add_image.php>";
	}

	if ($file_name == "")
	{
		echo "You must name the file. ";
		echo "<meta http-equiv='REFRESH' content=3;url=add_image.php>";
		exit();
	}

	if ($url != "")
	{
		copy( $url, "images/full/".$file_name );

		$image_to_thumbnail = $file_name;

		include "resize_image.php";

		echo "image coppied";
		echo "<br>";
		echo "<img src=images/thumbs/t_".$image_to_thumbnail." />";
		echo "<br>";
		echo "<img src=images/full/".$image_to_thumbnail." />";

	}
}
?>

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/82887-another-wtf-parse-error/
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.