Page 1 of 1

File Upload Glitches

Posted: Sun May 25, 2003 3:22 pm
by Jackdaw
:arrow: :?: Got a problem with an upload script I modified to try and cope with having globals switched off - The scpript does actually upload files (eventually) after going back to the "Click here to view File" page following The Error 404 page and refreshin it - can anyone suss out why it doesn't upload first time around.

Heres the script:

Code: Select all

<?php 	
	$_FILES['file']['name'];
	$_FILES['file']['size'];
	$_FILES['file']['type'];
	$_FILES['file']['tmp_name'];
	global $uploaddir;
	
	print "<pre>";
	
	if($_FILES['file']['name'] !="")
	{
	move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir . $_FILES['file']['name'])
	or die("Could not copy the file");
	//print_r($_FILES);
	}
	else {die("No file specified");}	
?>
<html>
<head> <title>Upload complete</title> </head>
<body>
<h3>File upload succeeded...</h3>
<ul>
<li>Sent: <?php echo $_FILES['file']['name']; ?>
<li>Size: <?php echo $_FILES['file']['size']; ?> bytes
<li>Type: <?php echo $_FILES['file']['type']; ?>
</ul>

<a href="<?php echo $_FILES['file']['name'] ?>">Click here to view file</a>

</body>
</html>
mod_edit: added php tags

Following on from this I'd like to dump images into a subdir - e.g. /images
How can I achieve this???

Hope someone can help!!!
8) 8) 8)

Posted: Sun May 25, 2003 6:10 pm
by AVATAr
check: <a href="<?php echo $_FILES['file']['name'] ?>">Click here to view file</a>


you have to use something like:
<a href="<?php echo $uploaddir.$_FILES['file']['name'] ?>">Click here to view file</a>