I am getting the values of posted data with php.
I am using:
if (isset($_POST['fieldname'])) {
$field1 = $_POST['fieldname'];
}
This works correctly and I can return the value using:
echo $field1;
My problem is that there is a field called ul_image which contains the name of an image and it's for upload.
I've tried:
if (isset($_POST['ul_image'])) {
$field2 = $_POST['ul_image'];
}
echo $field2;
but this returns nothing.
I'm out of ideas so does anyone have any suggestions?
The file data is contained in $_FILES['ul_image']
. It contains an array with the following keys: name
(original filename), type
(MIME type), size
(file size in bytes), tmp_name
(temporary path on your server), error
(any errors).
Then to store the file permanently use move_uploaded_file($_FILES['ul_image']['tmp_name'], $destination)
. The reason is added security; this function makes sure a hacker has not manipulated your script to move arbitrary files on your server.
If the input type is 'file', it ends up in the $_FILES array, not in the $_POST array. You will then have to find a way to actually get the image to your server - or wherever.
Start reading here: http://nl3.php.net/move_uploaded_file