Don't let CGI confuse you.
All php scripts ARE CGI scripts. (pretty much)
So forget about perl and the cgi-bin etc..
All you need to do send the form that uploads the picture to a php script.
You do this by writing action= and the name of the php script.
Also you must set enctype to 'multipart/form-data' for file uploads.
ex:
<form enctype='multipart/form-data' action='uploadPic.php' method=post>
<input type='File' name='myPicture'>
...
When the form is sent (along with the picture) uploadPic.php will be run and given all the information about what was send in the form. The information about uploaded files will be in the variable
$HTTP_POST_FILES.
Also the variable $myPicture will be set as a handler for the picture. (assuming the name attribute in the input tag was 'myPicture').
$HTTP_POST_FILES['myPicture']['tmp_name'] will point to where the picture is currently stored on the server (defalut temp dir);
$HTTP_POST_FILES['myPicture']['name'] contains the name of the picture as it was on the client computer.
$HTTP_POST_FILES['myPicture']['type'] and $HTTP_POST_FILES['myPicture']['size'] contain the mime type and size (in bytes) of the picture.
You can use the function is_uploaded_file to check if the picture was sent.
Since the server will initially place the picture in a temporary directory, you need to use the function move_uploaded_file to place the picture where you want it on the server.
// keep the same name
$picName = $HTTP_POST_FILES['myPicture']['name'];
// check if we got the file
is_uploaded_file($myPicture) {
// place the file in the pictures directory
move_uploaded_file($myPicture, "/pictures/$picName");
$msg = "Got the picture!";
}
else $myPicture = "No picture received";
...
...
echo $msg
...