Jump to content

File Not Uploading


947740

Recommended Posts

Is this PHP code correct?:

 

if(!isset($_POST['MAX_FILE_SIZE']) || $_POST['filename'] == "") {

echo <<<END
<form enctype="multipart/form-data" method='POST' action='upload.php'>
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<!--Destination (Include slash afterwards): <input type='text' name='destination' /><br />-->
File: <input type='file' name='filename' /><br />
<input type='submit' name='uploaded' value='Upload' /><br />

</form>

END;

}
else {
	$destination = 'uploads/'.basename($_FILES['filename']['name']);
echo $destination;
	move_uploaded_file($_FILES['filename']['tmp_name'],$destination) or die("could not upload");
}

 

EDIT: the file this is in is called upload.php.

 

I do not think it is even trying to upload anything.  I press submit, and I think it just refreshes without doing anything.

Link to comment
https://forums.phpfreaks.com/topic/116249-file-not-uploading/
Share on other sites

added a check to your script:

<?php
if (isset($_GET['upload']) && $_GET['upload'] == "success"){
print "<center><strong>Uploaded file!</strong></center>";
}
if(!isset($_POST['MAX_FILE_SIZE']) || $_POST['filename'] == "") {
echo <<<END
<form enctype="multipart/form-data" method='POST' action='upload.php'>
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<!--Destination (Include slash afterwards): <input type='text' name='destination' /><br />-->
File: <input type='file' name='filename' /><br />
<input type='submit' name='uploaded' value='Upload' /><br />
</form>
END;
}
else {
$destination = 'uploads/'.basename($_FILES['filename']['name']);
echo $destination;
move_uploaded_file($_FILES['filename']['tmp_name'],$destination) or die("could not upload");
header("location:?upload=success");
exit();
}

Link to comment
https://forums.phpfreaks.com/topic/116249-file-not-uploading/#findComment-597823
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.