Hello All,
Having a real hard time trying to figure out why my upload script will not work. Sort of new to this, but please forgive me if you all think I am an idiot.
The error messages I get are (Line 40 is marked below in save.php):
Warning: fopen("","r") - Success in /home/totalaccess/www/scontrol/save.php on line 40
Warning: Supplied argument is not a valid File-Handle resource in /home/totalaccess/www/scontrol/save.php on line 40
Obviously the file name, path, and image info are NOT being passed to the save page, and I don't know why. All other fields are being passed perfectly fine.
I have a form with multiple text fields along with the field <input type=file>:
<form method="post" action="verify.php" enctype="multipart/form-data">
<input type="hidden" name="speaker_id" value="<? echo $result_array["speaker_id"] ?>">
<?
echo $result_array["speaker_id"];
echo "<br>";
?>
<table border="0">
<tr valign="top">
<td width="10"><? if (in_array ("name_first", $result_array["errors"])) echo "<span style=\"background-color: #FFFF00\">"; ?>First Name:<? if (in_array ("name_first", $result_array["errors"])) echo "</span>"; ?> </td>
<td><input type="text" name="name_first" size="30" maxlength="30" value="<? echo stripslashes(htmlspecialchars($result_array["name_first"])); ?>"></td>
</tr>
...
<tr valign="top">
<td colspan="2">Small Photo Image File to Upload:</td>
</tr>
<tr valign="top">
<td colspan="2"><INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000"><input type="file" name="form_data1" size="40"></td>
</tr>
...
After submitting it goes to a file verify.php which makes sure there is an entry for last name, if there is, it goes to a file called save.php which should save all the information for me. Everything is working except for the file upload.
save.php:
LINE 40: $data = addslashes(fread(fopen($form_data1, "r"), filesize($form_data1)));
$photoresult1=mysql_query("REPLACE INTO smphoto_bin_data (speaker_id, bin_data, filename, filesize, filetype) VALUES ('" . $HTTP_SESSION_VARS['$speaker_id'] . "','$data','$form_data1_name','$form_data1_size','$form_data1_type')") or die(mysql_error());
I have also tried using $HTTP_SESSION_VARS["form_data1"] to no avail.
Thank you for your time and help.
Chris