Forum Moderators: coopster
The following snippet:
=================================================
<?
function processImage()
{
?>
<pre>
<?
print_r($_POST);
print_r($_FILES);
print_r($HTTP_POST_FILES);
print_r($_COOKIE);
?>
</pre>
<?
$imageName = empty($_FILES['picture']['name'])? die ("$user, You must enter a file! <BR> <a href='javascript:history.back()'>BACK</a>") : mysql_real_escape_string($_FILES['picture']['name']);
echo "IMAGENAME: $imageName";
...
========================================
Results with:
========================================
Array
(
[description] => pp
[type] => 1
[submitButtonName] => Submit Image
)
Array
(
[picture] => Array
(
[name] => cinder.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpyOBVJF
[error] => 0
[size] => 151172
)
)
Array
(
[ausUID] => 7
)
IMAGENAME:
===========================================
The $imageName variable is not getting filled but you can see it in the array.
file_uploads is on in php.ini
Any suggestions?
FALSEotherwise you would likely see your image name being printed out there.
var_dump [php.net]($imageName);
And now I get:
======================
Array
(
[description] => y
[type] => 1
[submitButtonName] => Submit Image
)
Array
(
[picture] => Array
(
[name] => cinder.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpuhKieg
[error] => 0
[size] => 151172
)
)
Array
(
[ausUID] => 7
)
bool(false) IMAGENAME:
FALSEif the variable has a non-empty and non-zero value. And your variable has a non-empty, non-zero value. The logic you have says if the variable is empty then exit the script and dump the message with a back button. However, if it is true, escape the string for further processing. Go back to your original logic and dump the var where you were printing it out earlier.
$imageName = empty($_FILES['picture']['name'])? die ("$user, You must enter a file! <BR> <a href='javascript:history.back()'>BACK</a>") : mysql_real_escape_string($_FILES['picture']['name']);
?><BR><?
var_dump ($imageName);
=======================
Result is:
=======================
Array
(
[description] => y
[type] => 1
[submitButtonName] => Submit Image
)
Array
(
[picture] => Array
(
[name] => cinder.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpgcIKz5
[error] => 0
[size] => 151172
)
)
Array
(
[ausUID] => 7
)
string(10) "cinder.jpg"
bool(false)
=================
Wasn't sure I understood you correctly so I put it in two places.
I would also encourage you to turn up your error_reporting [php.net] during testing (not in your LIVE environment though) so these errors will be more prominent while you develop and test.
Glad you got it sorted!