Jump to content

Upload Error


3raser

Recommended Posts

This is my first time ever working with this type of stuff with PHP. So, I basically got this code from a tutorial at Tizag on how to upload files to your webiste. But everytime I do, I get an error message. I don't get a PHP error, I just get it from the code. "There was an error uploading the file, please try again!"

 

<?php
session_start();
include("includes/mysql.php");
include("includes/config.php");

?>

<title><?php echo $title; ?></title>

<?php

if(!$_SESSION['user'])
	{
		echo "Your not allowed to upload plugins! <a href='index.php'>Go Home</a> or <a href='register.php'>Make an account</a>.";
	}
	else
	{
	$description = $_POST['description'];
	$description = mysql_real_escape_string($description);
	$ip = $_SERVER['REMOTE_ADDR'];
	$date = date('m-d-y');
	$title = $_POST['title'];
	$title = mysql_real_escape_string($title);

	$query = mysql_query("SELECT COUNT(id) FROM mods");
	$finish_query = mysql_fetch_assoc($query);

	$output = $finish_query['COUNT(id)'] + 1;
	echo $output;
	$_FILES['uploadedfile']['name'] = $output;
	echo $_FILES['uploadfile']['name'];

		$target_path = "mods/";

		$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

		if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
		echo "The mod ".  basename( $_FILES['uploadedfile']['name']). 
		" has been uploaded. Check it out HERE.";

		mysql_query("INSERT INTO mods VALUES('', '$ip', '$date', '$title', '$description', '$user')");

		} else{
		echo "There was an error uploading the file, please try again!";
		}
	}
include("includes/footer.php");
?>

Link to comment
https://forums.phpfreaks.com/topic/223802-upload-error/
Share on other sites

Post the form also, please.

 

Sure thing. :)

 

<?php
session_start();
include("includes/mysql.php");
include("includes/config.php");

?>

<title><?php echo $title; ?></title>

<?php

if(!$_SESSION['user'])
	{
		echo "Your not allowed to upload plugins! <a href='index.php'>Go Home</a> or <a href='register.php'>Make an account</a>.";
	}
	elsea
	{
		echo '<form enctype="multipart/form-data" action="upload.php" method="POST">
		<input type="hidden" name="MAX_FILE_SIZE" value="100000000 byte" />
		Choose a Plugin to Upload: <input name="file" type="file" /><br />
		<b>Title:</b> <input type="text" name="title"><br/>
		<b>Description</b><br/><textarea name="description" cols="45" rows="25"></textarea>
		<br/>
		<input type="submit" value="Upload Plugin" />
		</form>';

		echo "<br/><br/>";
		echo "NOTE: Uploading any harmful programs and/or files that can invade another users privacy, harm their computer, or uploading any files like malware, viruses, or trojans will result in an INSTANT, PERMANENT, IP Ban.";
	}
?>

<? 
include("includes/footer.php");
?>

Link to comment
https://forums.phpfreaks.com/topic/223802-upload-error/#findComment-1156775
Share on other sites

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.