railsbox railsbox - 17 days ago 4
PHP Question

ContentType: multipart/form-data when POSTing access_token to a resource

I need Your help, i am implementing OAuth2 Services getting library from

https://github.com/bshaffer/oauth2-server-php


Every thing is woking fine but when i used
enctype="multipart/form-data"
in form getting error
The access token provided is invalid


My Form

<form action="contact.php" method="post" enctype="multipart/form-data" name="contact" id="conact">
<table>
<tbody>
<tr>
<td>Image</td>
<td><input type="file" name="image" id="image" value="" /></td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" name="name" id="name" maxlength="25" value="" /></td>
</tr>
<tr>
<td>Status</td>
<td><input type="text" name="status" id="status" maxlength="25" value="" /></td>
</tr>
<tr>
<td>Access Token</td>
<td><input type="text" name="access_token" id="access_token" value="" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" id="submit" value="Submit" /></td>
</tr>
</tbody>
</table>
</form>


But When i remove it
enctype="multipart/form-data"
everthing is working file but image is not upload.

My contact.php have

if (!$server->verifyResourceRequest(OAuth2\Request::createFromGlobals())) {
$response[]=$server->getResponse()->send();
die;
}
This Code is Checking Valid and Invalid Access Token


Please Help.
Thanks

Answer

I am not get these answer yet so i use the alternative method for this I passed the access token in action Like this

<form action="contact.php?access_token=" method="post" enctype="multipart/form-data" name="contact" id="conact">
  <table>
    <tbody>
      <tr>
        <td>Image</td>
        <td><input type="file" name="image" id="image" value="" /></td>
      </tr>
      <tr>
        <td>Name</td>
        <td><input type="text" name="name" id="name" maxlength="25" value="" /></td>
      </tr>
      <tr>
        <td>Status</td>
        <td><input type="text" name="status" id="status" maxlength="25" value="" /></td>
      </tr>
      <tr>
        <td colspan="2"><input type="submit" name="submit" id="submit" value="Submit" /></td>
      </tr>
    </tbody>
  </table>
</form> 

It working fine.

Comments