samedi 28 février 2015

Uploading image files and php not registering any inputs [on hold]

I have a fairly simple HTML form with a file input and I'm trying to post it to a block of PHP code.


I use this same method in other places on my website and it works perfectly, there must be some very basic (probably embarrassing) thing I'm overlooking or don't understand.


**I have a functioning method call (upload_image) and that method works, that's not the issue. The issue is in the html form being read by the php code above it.


HTML & PHP:



<?php

echo 'It reads to this point';

if(empty($_FILES['aca']))
print_r("Damn");
if(isset($_FILES['aca']) === true)
{
echo 'something';
if(empty($_FILES['aca']['name']) === true)
{
echo 'Please choose a file! <br>';
}
else
{

$allowed = array('jpg', 'jpeg', 'gif', 'png');

$file_name = $_FILES['aca']['name'];

$file_extn = strtolower(end(explode('.', $file_name)));
$file_temp = $_FILES['aca']['tmp_name'];
echo '<br>';
echo '<br>';
print_r($_FILES['aca']['tmp_name']);
echo '<br>';
echo '<br>';
if(in_array($file_extn, $allowed) === true) {

upload_image($file_temp,$file_extn);

echo 'You have uploaded a picture!';
echo '<b><h3>Press submit again to finish the upload</h3></b>';
//echo "<script>window.top.location='../hidden/viewPNM.php?id=$permi'</script>";


}
else
{
echo 'Incorrect File Type!! <br> Allowed: ';
echo implode(', ', $allowed);

}

}

}


?>
<form action="" method="post" id="aca" enctype="multipart/form-data">
<input type="file" id="aca" name="aca"> <input type="submit">
</form>

Aucun commentaire:

Enregistrer un commentaire