I am having an issue with my image upload script in firefox. The images do upload to my site in the proper place but it dosn't save the link to my database tables.
for example please visit
http://www.warparty.net/profile/profile.php
user name and pass = 'test'
and try to upload a picture
When this is done in IE the url for the image displays in the text box, then when you save the file it stores the link from the text box to my mysql database table.
NOW when you do this in firefox, the link dosn't show up in the box, and nothing gets saved to my table.
My profile edit script where the user uploads a picture is:
$content .= "<tr><td><font color=\"black\" size=\"1\" face=\"sans-serif\">Personal Image:</td><td><input type=\"text\" name=\"imageurl\" size=\"20\" maxlength=\"250\" value=\"$imageurl\"> <a href=\"javascript:upload();\">Upload An Image </a><br><br><font color=\"black\" size=\"1\" face=\"sans-serif\">NOTE IMAGE'S WITH A SPACE IN THE NAME WILL RESULT IN THE IMAGE NOT BEEING PROPERLY DISPLAYED! png, bmp, jpg and jpeg only. </td></tr>";
===========================
My Upload script is as follows:
Upload Processor (upload.php)
require("mainfile.php");
function index() {
global $dbi;
checkuser();
echo "<html>";
echo "<head>";
echo "<title>Upload A File</title>";
echo "</head>";
echo "<body>";
echo "<form method=\"post\" action=\"upload.php?op=upload\" enctype=\"multipart/form-data\">";
echo "<center><table border=\"0\">";
echo "<tr><td>Upload A File:</td></tr>";
echo "<tr><td><input type=\"file\" name=\"file\"></td></tr>";
echo "<tr><td align=\"center\"><input type=\"submit\" value=\"Upload\"> <input type=\"button\" value=\"Cancel\" onclick=\"window.close()\"></td></tr>";
echo "</table></center>";
echo "</form>";
echo "</body>";
echo "</html>";
}
function upload() {
global $dbi, $uploaddir, $weburl;
checkuser();
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
$ext = strrchr($uploadfile, ".");
$ext = strtolower($ext);
$exerr = 1;
if ($ext == ".jpg") { $exerr = 0; }
if ($ext == ".jpeg") { $exerr = 0; }
if ($ext == ".gif") { $exerr = 0; }
if ($ext == ".png") { $exerr = 0; }
if ($ext == ".bmp") { $exerr = 0; }
$randnum = rand(00000, 99999);
$filename = str_replace(".", "", $FILES['file']['name']);
$filename = str_replace(" ", "", $_FILES['file']['name']);
$furl = $weburl . $filename . "_" . $randnum . $ext;
if ((move_uploaded_file($FILES['file']['tmp_name'], $uploaddir . $filename . "" . $randnum . $ext)) && ($exerr == 0)) {
echo "<script language=\"javascript\">\n";
echo "opener.profileform.imageurl.value = '$furl';\n";
echo "window.close();\n";
echo "</script>\n";
} else {
echo "An error occurred... please try again.<br>Note: The file type you are uploading may not be an image... please use only files with the following extensions: .jpg, .jpeg, .gif, .png, .bmp.\n";
}
}
switch($op) {
default:
index();
break;
case "upload":
upload();
break;
}
?>
If you need to view more of my code or have any suggestions please reply to this post.