Jump to content

Upload File with POST mehtod (form)


TheUnknownCylon

Recommended Posts

Hi all,

 

I've been working on a script what should do something like this.

 

I upload a file through a simple form. PHP Get's this file and storest it into a $_FILE['x']['tmp_name']. The PHP calls another website with fopen() to get the source of the requested page. With that pagerequest PHP also sends the file.

 

User uploads file -> File in my PHP File -> Call to another site with FILE.

 

How can I do this?

 

Here is the basic code.:

 

$data = http_build_query(
	array( 
	'MAX_FILE_SIZE' => '1548576',
	'aff' => '',
	'type' => 'blank',
	'where' => 'iframe',
	'fileupload' => $_FILES['fileupload']['tmp_name'],
	'submit' => $_POST['submit']
	)
);	

$params = array('http' => array(
                  'header' => 'Content-Type: multipart/form-data',
                  'method' => 'POST',
                  'content' => $data                  
               ));

$context = stream_context_create($params);
$fp = @fopen('test.php', 'rb', false, $context);
$response = @stream_get_contents($fp);
fclose($fp);

 

When I run this code the last page does not recognize the attached file.

My first thought is that the file not should be included in the params list. But then I don't know how to it correct. Searching the web didn't help me out of this.

 

Hope you can help me!

Link to comment
https://forums.phpfreaks.com/topic/96569-upload-file-with-post-mehtod-form/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.