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.