I initialize the variables, use move_uploaded_file function and then I write a basic form user will use to upload their photo. I am trying to print at lease an error_msg or a sucess_msg showing wether they had sucess in loading the file or not. nothings is showwing up. Help!
$error_msg = "";
$success_msg = "";
$name2 = "";
if ($_POST['parse_var'] == "pic"){
if (!$_FILES['fileField']['tmp_name']) {
$error_msg = '<font color="#FF0000">ERROR: Please browse for an image before you press submit.</font>';
} else {
$maxfilesize = 51200; // 51200 bytes equals 50kb
if($_FILES['fileField']['size'] > $maxfilesize ) {
$error_msg = '<font color="#FF0000">ERROR: Your image was too large, please try again.</font>';
unlink($_FILES['fileField']['tmp_name']);
} else if (!preg_match("/\.(gif|jpg|png)$/i", $_FILES['fileField']['name'] ) ) {
$error_msg = '<font color="#FF0000">ERROR: Your image was not one of the accepted formats, please try again.</font>';
unlink($_FILES['fileField']['tmp_name']);
} else {
$newname = $id'.jpg';
$place_file = move_uploaded_file( $_FILES['fileField']['tmp_name'], "images/$id/".$newname);
$success_msg = '<font color="#009900">Your image has been updated, it may take a few minutes for the changes to show... please be patient.</font>';
}
} // close else that checks file exists
}
<table width="709" align="center" cellpadding="5">
<form action="edit_profile.php" enctype="multipart/form-data" method="post" name="pic1_form" id="pic1_form">
<!-- <tr>
<td width="125" class="style7"><div align="center"><strong>Please Do First →</strong></div></td>
</tr>-->
<tr>
<td width="16%"><?php print "$user_pic"; ?></td>
<td width="74%">
<input name="fileField" type="file" class="formFields" id="fileField" size="42" />
50 kb max
</td>
<td width="10%">
<input name="parse_var" type="hidden" value="pic" />
<input type="submit" name="button" id="button" value="Submit" />
</td>
</tr>
</form></table>
I don’t see anywhere in that code where you are echoing the error or success message.