Hi everyone, i wanted to upload an excel file in a form and then display/edit the file from the form. Currently, the file can be uploaded at localhost but when i try to upload in server it was not successful. I would also want to view/edit the file and save the changes. Appreciate for your advise. Thanks a lot.
form.html
<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br /> <input type="submit" value="Upload" />
</form>
upload.php
<?php
$con=mysqli_connect("localhost","user","","pq");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$uploaded_size ='';
$uploaded_type = "";
$uploaded = "" ;
$target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1;
//This is the sizing condition
if ($uploaded_size > 350000)
{ echo "Your file is too large.<br>"; $ok=0; }
//This is the file type limit condition
if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; }
if ($uploaded_type =="text/css") { echo "No CSS files<br>"; $ok=0; }
if ($uploaded_type =="text/javascript") { echo "No Javascript files<br>"; $ok=0; }
if ($ok==0) { Echo "Sorry your file was not uploaded"; }
else {
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{ echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"; }
else
{ echo "Sorry, there was a problem uploading your file.";
}
}
?>