Jump to content

File Uploading


coolgamer48

Recommended Posts

Okay, so I'm trying to make a file upload page. I've made one successfully before, but when I tried this new one, it doesn't work. Here's the code for the .php file:

<html>	<head>		<title>Alec Benzer - Send Me a File</title>		<link rel = "stylesheet" type = "text/css" href = "stylesheet.css" />	</head>	<body>		<table width = "100%" cellpadding = "20" cellspacing = "0">			<tr>				<?php include("header.php"); ?>			</tr>			<tr>				<?php include("sidebar.php");?>				<?php include("maintd_pre.php");?>					<h1>Send Me a File</h1>					Hey, do you ever just get the urge to send someone a random file? I know I do. Well, while most people would force you to email them the file the old boring way, I took the liberty of creating a page for it. Just upload your files here.					<h2>File Upload</h2>					<form action = "sendme_file.php" method = "post" enctype = "multipart/form-data">						File: <input type = "file" name = "file" /><br />						<input type = "submit" value = "Upload" />					</form>					<?php						if ($_FILES["file"]["size"] > 0)						{							if ($_FILES["file"]["size"] > 20000)							{								echo "<br />".$_FILES["file"]["name"]." is too large. Maximum upload size is 20KB.";							}							else							{								if ($_FILES["file"]["error"] > 0)								{									echo "<br />".$_FILES["file"]["name"]." could not succesfully upload. Error: ".$_FILES["file"]["error"];								}								else								{									if (file_exists("uploads/".$_FILES["file"]["name"]) == TRUE)									{										echo "<br />".$_FILES["file"]["name"]." already exists.";									}									else									{										if (move_uploaded_file($_FILES["name"]["tmp_name"],"uploads/".$_FILES["file"]["name"]) == TRUE)										{											echo "<br />".$_FILES["file"]["name"]." uploaded succesfully.";										}										else										{											echo "<br />".$_FILES["file"]["name"]." could not upload.";										}									}								}							}						}					?>				</td>			</tr>			<tr>				<?php include("footer.php");?>			</tr>		</table>	</body></html>

The page is live here: http://alecbenzer.awardspace.com/sendme_file.phpI'm pretty sure the problem is with the move_uploaded_file() function (based on the errors I generate).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...