mardi 30 juin 2015

Php: $_POST is not set after form is sent to iframe

I have just spent 4 hours researching and nothing has fixed my problem, so here I am. I am trying to design my own little chunk file uploader, and all is working quite well.

I have a main upload page that lets you set a file to upload. It then automatically cuts the first chunk out of the bytes of the file, and puts it into a form, along with some other bits of information:

    <form id="hiddenform" name="hiddenform" action="SecretChunkUploader.php" target="iframe" enctype="multipart/form-data" method="post">
        <hidden id="Bytes" name="Bytes" value="" />
        <hidden id="Pass" name="Pass" value="<?php echo $_POST['Pass'];?>" />
        <hidden id="FileName" name="FileName" value="" />
        <hidden id="PackageNumber" name="PackageNumber" value="" />
</form>

Every <hidden> has its value correctly sent when the form is submitted through this javascript command:

document.forms["hiddenform"].submit();

The form is submitted to an iframe:

<iframe id="iframe" name="iframe" onload="" style="display:block"></iframe>

When submitted, the iframe navigates to the page specified in the form's action attribute.

Everything works well, except for when the form is received. The page loads, but there is no post data, and the variables for post are not set.

Here is the code for SecretChunkUploader.php:

    <?php
echo "Password: ".$_POST["Pass"]."<br/>";
echo "FileName: ".$_POST["FileName"]."<br/>";
echo "PackageNumber: ".$_POST["PackageNumber"]."<br/>";
echo "Bytes: ".$_POST["Bytes"];
?>

The loaded page from SecretChunkUploader.php looks like:

Password:
FileName:
PackageNumber:
Bytes: 

I have tried testing isset() and it returned false for all of the post variables.

What on Earth am I doing wrong? I have tested and know that the form is fully working, it just doesn't pass the values onwards.

Thanks in advance for any help!

Aucun commentaire:

Enregistrer un commentaire