Sending FILE post data through PHP code
-
Is there a way to send FILE post data through PHP code. I found a code which send common POST data: fputs($fp, "POST $path HTTP/1.1\r\n"); fputs($fp, "Host: $host\r\n"); fputs($fp, "Referer: $referer\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: ". strlen($data) ."\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $data); How do I send $_FILES data through POST. Is that posible?
Don't work hard, but work effectively. Travel guide | invest money
-
Is there a way to send FILE post data through PHP code. I found a code which send common POST data: fputs($fp, "POST $path HTTP/1.1\r\n"); fputs($fp, "Host: $host\r\n"); fputs($fp, "Referer: $referer\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: ". strlen($data) ."\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $data); How do I send $_FILES data through POST. Is that posible?
Don't work hard, but work effectively. Travel guide | invest money
they are referenced in a different variable...$_FILES. But you need to have an input element of the type files in your post form first. So someething like
Name:
Img:You would access the form elements with... $_POST['action'] for the submit button $_POST['user'] for the user field $_FILES['pict'] for the pict field. Keep in mind this is an array and has a number addition values. You can read more about that here http://www.php.net/manual/en/features.file-upload.php[^]
-
Is there a way to send FILE post data through PHP code. I found a code which send common POST data: fputs($fp, "POST $path HTTP/1.1\r\n"); fputs($fp, "Host: $host\r\n"); fputs($fp, "Referer: $referer\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: ". strlen($data) ."\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $data); How do I send $_FILES data through POST. Is that posible?
Don't work hard, but work effectively. Travel guide | invest money
Yes, it is possible. To save you having to encode the request yourself, I would recommend using something like http://pear.php.net/package/HTTP_Request2[^] - it has an
addUpload
method for uploading files.