2

I have an app that sends a request to my server, you can see the code below:

Method: POST
multipart/form-data; boundary=—————————14737809831466499882746641449
Content-Type Content-Disposition: form-data; name=\'Stackoverflow\'; filename=\'.%@\'\r\n
Content-Type: application/octet-stream\r\n\r\n

This request works and I receive a real request in my PHP Server, the problem is that I am not knowing catch these values with PHP, since the commands $_GET['name'] and $_POST['name'] are not working.

How can I handle this parameters?

Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
Lacrifilm
  • 253
  • 5
  • 15
  • Try to make `$_REQUEST['name'] ` – KubiRoazhon Apr 12 '16 at 15:25
  • 1
    The `Content-Type` header seems to be wrong. Have a look at http://stackoverflow.com/questions/14962592/whats-content-type-value-within-a-http-request-when-uploading-content for content types with file uploads. – bspellmeyer Apr 12 '16 at 15:30
  • What are you posting in your form? Are you trying to upload a file? – Lelio Faieta Apr 12 '16 at 15:34
  • @LelioFaieta yes I upload a file.. – Lacrifilm Apr 12 '16 at 15:39
  • 2
    Then have a look at the $_FILES array, not get or post. You will find the file and all the related information – Lelio Faieta Apr 12 '16 at 15:41
  • The real problem with this code, is because I lost my file that grab this informations, and I don't remember how to get this parameters, I remember that I use file get contents to grab the all request.... but how? I don't know... – Lacrifilm Apr 12 '16 at 15:54

2 Answers2

0

This is not much to solve the Problem.

Are you opening the site like that: http://www.example.com/index.php?getvar=test

or like that: http://www.example.com/index.php

?

in the second case it can't get an $_GET value because there is no variable

in the first case try to check if the variable exists like that: if(isset($_GET['getvar']))

and check if the $_POST variable exists before using it.

if not you should look over your code and correct your mistakes.

If you need more help please post the php code in here.

0

you should look into $_FILES['filename'] ('filename' is name of parameter containing file), there will be info about uploaded file.

it contains array, from which you probably want 'tmp_name' key ($_FILES['filename']['tmp_name']), which contains temporary location of stored file. This temporary file will be deleted after the end of request, so you will want to move it elswhere.

not sure if docs are helpful in this situation, but there they are:

http://php.net/manual/en/reserved.variables.files.php

Jimmmy
  • 579
  • 12
  • 26