Current location: Hot Scripts Forums » Programming Languages » PHP » Firefox Image Upload Issue


Firefox Image Upload Issue

Reply
  #1 (permalink)  
Old 02-25-07, 12:27 AM
klassix klassix is offline
Newbie Coder
 
Join Date: Dec 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Question Firefox Image Upload Issue

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:

PHP Code:

$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:

PHP Code:

## 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(0000099999);
    
    
$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 send me an email at mr.clinton.smith@gmail.com or reply to this post.

Last edited by Christian; 02-25-07 at 03:16 AM. Reason: Please use [php] tags when posting PHP code.
Reply With Quote
  #2 (permalink)  
Old 02-25-07, 07:50 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Try window.opener.imageurl.value...
Reply With Quote
  #3 (permalink)  
Old 02-25-07, 10:46 AM
klassix klassix is offline
Newbie Coder
 
Join Date: Dec 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
hmm

sorry i am a bit of a noob, i am assuming you ment for me to replace

this line
echo "opener.profileform.imageurl.value = '$furl';\n";

with this line

echo "window.opener.imageurl.value = '$furl';\n";

which didn't work...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image upload using php. Tjobbe PHP 5 09-28-06 09:07 AM
Image Upload Perms automatically set to 600 progress Perl 2 10-05-05 12:19 PM
ASP upload prob minority ASP 1 06-27-05 08:35 AM
image resize and upload ascanio PHP 0 06-25-05 06:37 PM
Image upload and if / else mdhall PHP 4 11-14-04 03:12 PM


All times are GMT -5. The time now is 05:57 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.