Socket program message file for php

Yesterday I asked a question about socket file data in php page.

Link here

Upload and POST file to PHP page

When I follow the path, I changed my code.

char *str="POST /path/upload_file.php HTTP/1.0 \n Host: 00.00.00.00 \n   Content-Disposition: name=2.jpg;filename=2.jpg\r  " ;

write(sockfd, buf, filestat.st_size);
sprintf(send1,"%s%s\r\n",str,buf);
retval= send(sockfd,send1,sizeof(send1),0);

When I run the program, I can get

Result: 501 Method not implemented

Method not implemented

 to / index.html is not supported.

Invalid method in request


Apache / 1.3.39 Server on localhost Port 80

I think this is possible: 1. can apache not support something?
   (my apache does not support ssl) 2. Is the HTTP protocol not the details? 3. other?

Many thanks.

+3
source share
1 answer

There are several problems in the code.

-, Host HTTP 1.1 HTTP 1.0.

-, , \r\n, \n.

-, Content-Disposition , .

, multipart/form-data. , , . .

( PHP, ). .

+1

Source: https://habr.com/ru/post/1776605/


All Articles