Upload file problem

A

Anonymous

Guest
Hi there,
i have read in the forums that i need to enable uploading for the webserver. Does that include for apache 2? I went through the config for it, & i can't find any upload thing for apache.

I have enable upload in php to this folder "e:/upload". But, it is unable to upload the file. No error was displayed, only the message "Couldn't copy the file" which is in the code. This is the html code, followed by the php code.

<html>
<head>
<title>Upload a file</title>
</head>
<body>
<h1>Upload a File</h1>

<form method = "post" Action = "do_upload.php" enctype = "multipart/form-data">

<P><strong>File to be Upload : </strong><br>
<input type = "file" Name = "img1" size="50"></p>

<p><input type = "submit" Name = "submit" value="upload file"></p>

</form>
</body>
</html>


<?

if ($img1_name != "") {
@copy("img1", "e:/upload/$img1_name") or die("Couldn't copy the file");

} else {
die("No input file specified");
}
?>

<html>
<head>
<title>Successful File Upload</title>
</head>
<body>
<h1>Success!</h1>
<P>You send :<? echo "$img1_name"; ?>, a <? echo "img1_size"; ?> byte file with a mime type of <? echo "$img1_type"; ?> </p>

</body>
</html>
 
Try this one:
Code:
<form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> 
<input type="hidden" name="MAX_FILE_SIZE" value="2048000"> 
Send files:<br> 
<input type="submit" value="Transfer"> 
</form> 

<?php 
if ($HTTP_POST_VARS){
	$dir = "my_dir":
	$filename = $_FILES['userfile']['name'];
	if ( !@copy ( $_FILES['userfile']['tmp_name'] , $dir."/".$filename) ){
		echo "<b>".$file." </b>couldn't be copied !!<b><br>";
	}else{
		echo "<b>".$file."</b> has been succesfully copied!<br>";
	}
}

?>
And be sure that permissions for that folder are set for upload.
 
Back
Top