Although I'm not under the impression that I'm doing well I'm not getting tired of explaining this. Someday I might write it in a way that is understandable
http is document-orientated. One request, one (and only one) document.
The data transfered is devided into two main parts, the header and the body.
- So you have
- request[request_header, request_body] client-->server
- response[response_header, response_body] server-->client
request_header contains the path of the requested document, cookie data that the client is willing to offer the server, ....
request_body e.g. contains POST-data
The server now tries to handle this request. In case of a php-script is requested, the server finds that file (hopefully) recognizes it as a script and invokes the php module/cgi.
However the response is produced, as long as it stays http it will be devided in response_header and response_body. Always the header first, then the body (that's the reason for "Warning: Cannot add header information - headers already sent by").
response_header includes the response code (e.g. 200 for ok, 404 for document not found, 500 internal server error, ....), content-type, everything that you set with header(...), cookies to be set (that's why you can't determine wether a cookie is accepted by the client or not on the same page), ...
response_body is e.g. what you see in the source view of your browser (html-document) or any other load-data there may be (a file downloaded, an image, ...)
ok, back to your script.
You're creating a html-document with php (not setting any other content-type via header(), the output is assumed to be text/html).
This document is transfered to the client where it is treated and parsed as html. (meanwhile the php-script has ended, the connection is dead and there's no relationship between the client-data and the script that produced it at this time).
Now your html-document contains like
<IMG SRC="image_reduce(picture.jpg)">.
The browser interprets it as "
here has to be an image and I can request it here: image_reduce(picture.jpg)". SRC is supposed to contain an URI to the document that contains the image data. This can be either absolute or relative. Your property is handled as relative, so the browser will generate a new request like e.g.
http://your.server/path/of/current/docu ... cture.jpg).
request_header now contains
path/of/current/document/image_reduce(picture.jpg) as path to requested document and that is certainly something your server can't handle, so it will send back a
404 - document not found.
What you have to do is creating a valid new request for the image's data, e.g.
Code: Select all
<img src="imagereduce.php?image=picture.jpg" />
now the request_header contains
/path/of/current/document/imagereduce.php?image=picture.jpg and if there is a imagereduce.php in the appropriate directory it will be invoked and image=picture.jpg will be passed to it as GET-data (for php4.2+ this is $_GET['image']='picture.jpg' by default).
The script now can send a new document, the image data, either original or reduced
