Jump to content

[SOLVED] Change page with URL


JacobMarshall

Recommended Posts

Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in /www/uuuq.com/j/m/a/jmarshall/htdocs/tests/uploads/file.php on line 97

 

<?php

#**********************************************
# Multiple File Upload						  *
#**********************************************

#**********************************************
# Change history							  *
# ==============							  *
# 10/10/2007 - WebDevBoost.co.uk			  *
#											  *
#**********************************************
# Description
# ===========
# The script is designed to allow you to upload multiple files in one go, the script also presents you with the variable option
# of keeping a files name or randomly renaming it.
# Remember, there maybe a a upload limit set by the server of 2MB, you can change this by changing the php.ini if you have access
#**************************************************************************************************


###/ VARIABLES - CHANGE ACCORDINGLY
define("VAR_BASE_DIRECTORY",	"");						 				#/ Your webhosting directory
define("VAR_UPLOAD_FOLDER",		"g452811/");				 				#/ Chmod directory 777 for successful upload
define("VAR_UPLOAD_DIRECTORY",	VAR_BASE_DIRECTORY.VAR_UPLOAD_FOLDER); 		#/ DO NOT EDIT
define("VAR_UPLOAD_FIELDS",		3); 										#/ Set number of upload fields
define("VAR_FILENAME_KEEP",		0);											#/ If set to 0 (Zero) the filename will generate randomly, if 1 (One) it will maintain filename


##/ Function that displays forms and is called by default
function defaultForm()
{

	echo "<form method=\"post\" enctype=\"multipart/form-data\">\n";

		for($i=0; $i < VAR_UPLOAD_FIELDS; $i++)
		{        
			  echo "<input name=\"file[]\" type=\"file\" id=\"file[]\" /><br />\n";
		}

	echo "<input name=\"Submit\" type=\"submit\" value=\"Submit\">\n";
	echo "<input name=\"filter\" type=\"hidden\" value=\"processForm\">\n";		##/ hidden value points the switch to processing
	echo "</form>\n";

	return;

}
#/ End of defaultForm

##/ Function that displays forms and is called by default
function processForm()
{

	for($i=0; $i < VAR_UPLOAD_FIELDS; $i++)
	{
		echo "";

		if(!empty($_FILES[file][size][$i])) 
		{ 
			if(VAR_FILENAME_KEEP==1)
			{
				##/ File maintaining upload name
				$fileName	 = $_FILES[file][name][$i];
			}
			else
			{
				##/ Filename randomized
				$fileName	 = rand(1,4000).rand(1,4000).rand(1,4000).rand(1,4000).rand(1,4000).'.' . substr($_FILES[file][name][$i], -3);
			}

			##/ Creating reference address 
			$newLocation	 = VAR_UPLOAD_DIRECTORY.$fileName;

			if(!copy($_FILES[file][tmp_name][$i],$newLocation)) 
			{
				echo "<b>Failed - ".$_FILES[file][name][$i]." would not copy to ".$newLocation."</b> (Check your upload directory and permissions)";
			}
			else
			{
				###/ SUCCESS /###

				#/ Stripping of VAR_BASE_DIRECTORY for better viewing and linking
				$urlShow = str_replace(VAR_BASE_DIRECTORY,'',$newLocation); 

				echo "<b>Uploaded successfully - <a href=\"$urlShow\" target=\"_blank\">$urlShow</a></b>";
			}
		} 
		else
		{
			echo "<b>No file uploaded</b>";
		}
		echo "<br />";
	}
	return;
}
#/ End of processForm

if (isset($_VAR_UPLOAD_FOLDER['id'] && $_VAR_UPLOAD_FOLDER['id'] == 'blabla')) {
$uploaddir = 'g795222/';
} else {
$uploaddir = 'g452811/';
}

    ##/ This object handles which function the application should call
switch($_POST[filter]) {
	case "processForm":
		processForm();
	break;
	default:
		defaultForm();
	break;
}
#/ End of Handling

?>

 

Link to comment
Share on other sites

You should spend some time learning about php, uploads, and upload security before putting code like you have started on a production website. If you are just looking for somebody to write code for you, there are many tutorials online, and you could just use their code. If you don't want to learn, and simply need code, try phpclasses.org.

Link to comment
Share on other sites

You guys are no use

 

Heh, apparently we're almost as useless as you. The difference being of course that we actually do know how to code.

 

If you are that desperate, send me a PM and we can discuss how much I will charge you to fix your problem.

Link to comment
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.