SitePoint Sponsor

User Tag List

Results 1 to 24 of 24
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2005
    Location
    New York, NY, U.S.
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unresponsive Script?

    Hey everyone. I've created a little file upload script, it's not complete yet, just the basic features are in place to make sure it works. It works perfectly except for one thing. It becomes unresponsive and I must click "continue" in firefox for it to continue and successfully finish. Any ideas why it would become unresponsive? Is it in my coding? I am using WAMP5 as the webserver to debug and check code. Here's the code:
    PHP Code:
    <?php
        
    // Define Constants
        
    define ("FILEREPOSITORY","C:\wamp\www\site\photos\\");
        
        
    //Check if file was posted
        
    if(is_uploaded_file($_FILES['photo']['tmp_name'])) {
          
            
    //Check to see if file was a photo/picture
            
    if(($_FILES['photo']['type']) != ('image/jpeg' || 'image/gif' || 'image/bmp')){
                echo 
    "<p>Photos must be JPG/JPEG, GIF, or BMP file formats please, most digital cameras will take pictures in JPG/JPEG format. If your camera takes pictures in TIFF or another format not currently supported by this site, please contact us and we will try to help remedy the problem. Thank you.</p>";
                
                } else { 
    //Move file to destination
                    
    $ownername $_POST['ownername'];
                    
    $dogname $_POST['dogname'];
                    
    $location $_POST['location'];
                    
                    if(
    $_FILES['photo']['type'] = "image/jpeg"){
                        
    $result move_uploaded_file($_FILES['photo']['tmp_name'],FILEREPOSITORY."\\" $dogname ".jpg");
                    } elseif(
    $_FILES['photo']['type'] = "image/gif") {
                        
    $result move_uploaded_file($_FILES['photo']['tmp_name'],FILEREPOSITORY."\\" $dogname ".gif");
                    } else {
                          
    $result move_uploaded_file($_FILES['photo']['tmp_name'],FILEREPOSITORY "\\" $dogname ".bmp");
                    }
                    if(
    $result == 1){ //check if file was moved successfully
                        
    echo "<p>successfully uploaded.<p/>";
                        } else { 
                          echo 
    "<p>Encountered a problem uploading the file.</p>";
                        }
                    }
            }
    ?>

  2. #2
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does it also do this in IE?

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2005
    Location
    New York, NY, U.S.
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, it does not.

  4. #4
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thats extremely weird. does the script still work if you press continue?

  5. #5
    SitePoint Zealot
    Join Date
    Dec 2005
    Location
    New York, NY, U.S.
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes

  6. #6
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think the browser is talking about a script it knows about. it doesnt know that your page is generated by php. you have some javascript in your html?

  7. #7
    SitePoint Evangelist
    Join Date
    Jan 2005
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it is a client side script that is causing the problem.

  8. #8
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah as php shows up the same in any browser. (thats the beauty of it)

  9. #9
    SitePoint Zealot
    Join Date
    Dec 2005
    Location
    New York, NY, U.S.
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the php is handling the form, but there isn't any javascript in my html anywhere.

  10. #10
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you post the whole page? something just ain't right.

  11. #11
    SitePoint Zealot
    Join Date
    Dec 2005
    Location
    New York, NY, U.S.
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Of course, here it is:
    HTML Code:
    <html>
    <head>
    </head>
    <body>
    	<form action="photoupload.php" enctype="multipart/form-data" method="post">
    		<ul>
    			<li>Owner's Name: <input type="text" name="ownername" value=""/></li>
    			<li>Dog's Name: <input type="text" name="dogname" value=""/></li>
    			<li>Location: <input type="text" name="location" value=""/><br />
    				<span>ex. New York, NY</span></li>
    			<li>Photo: <input type="file" name="photo" value=""/></li>
    		</ul>
    		<p><input type="submit" name="submit" Value="Upload" /></p>
    	</form>
    </body>
    </html>
    PHP Code:
    <?php
        
    // Define Constants
        
    define ("FILEREPOSITORY","C:\Program Files\Web Design\wamp\www\site\photos\\");
        
        
    //Check if file was posted
        
    if(is_uploaded_file($_FILES['photo']['tmp_name'])) {
          
            
    //Check to see if file was a photo/picture
            
    if(($_FILES['photo']['type']) != ('image/jpeg' || 'image/gif' || 'image/bmp')){
                echo 
    "<p>Photos must be JPG/JPEG, GIF, or BMP file formats please, most digital cameras will take pictures in JPG/JPEG format. If your camera takes pictures in TIFF or another format not currently supported by this site, please contact us and we will try to help remedy the problem. Thank you.</p>";
                
                } else { 
    //Move file to destination
                    
    $ownername $_POST['ownername'];
                    
    $dogname $_POST['dogname'];
                    
    $location $_POST['location'];
                    
                    if(
    $_FILES['photo']['type'] = "image/jpeg"){
                        
    $result move_uploaded_file($_FILES['photo']['tmp_name'],FILEREPOSITORY."\\" $dogname ".jpg");
                    } elseif(
    $_FILES['photo']['type'] = "image/gif") {
                        
    $result move_uploaded_file($_FILES['photo']['tmp_name'],FILEREPOSITORY."\\" $dogname ".gif");
                    } else {
                          
    $result move_uploaded_file($_FILES['photo']['tmp_name'],FILEREPOSITORY "\\" $dogname ".bmp");
                    }
                    if(
    $result == 1){ //check if file was moved successfully
                        
    echo "<p>successfully uploaded.<p/>";
                        } else { 
                          echo 
    "<p>Encountered a problem uploading the file.</p>";
                        }
                    }
            }
    ?>

  12. #12
    SitePoint Zealot
    Join Date
    Dec 2005
    Location
    New York, NY, U.S.
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there's got to be a reason for this. I really want to fix it, but I have no idea what the problem is.

  13. #13
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might want to post on the bugzilla at mozilla for Firefox. this really is extremely weird. Does this also give the popup in Opera? Mozilla?

  14. #14
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,609
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Do a View..Source in both IE and FF. Is the HTML source code any different?
    Ian Anderson
    www.siteguru.co.uk

  15. #15
    SitePoint Zealot
    Join Date
    Dec 2005
    Location
    New York, NY, U.S.
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Both of the source codes one IE and FF are identical

  16. #16
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I will chime in on a long shot, shouldnt this line:

    PHP Code:
    define ("FILEREPOSITORY","C:\wamp\www\site\photos\\"); 
    Be:

    PHP Code:
    define ("FILEREPOSITORY","C:\\wamp\\www\\site\\photos\\"); 
    Like I said, long shot. Since noone can figure this out thought I just give it a shot.

    Silly

  17. #17
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also right before the file field I believe you need something like this:


    PHP Code:
    <input type="hidden" name="MAX_FILE_SIZE" value="30000"
    Again just making sure all basic code is there. How big is the file your trying to upload? Have you tried a small image?

    Silly

  18. #18
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looking at your code again you have this:

    PHP Code:
    if($_FILES['photo']['type'] = "image/jpeg"
    Shouldnt it be:

    PHP Code:
    if($_FILES['photo']['type'] == "image/jpeg"
    Silly

  19. #19
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,609
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Bingo!

    = is an assignment

    == is a comparison
    Ian Anderson
    www.siteguru.co.uk

  20. #20
    SitePoint Zealot
    Join Date
    Dec 2005
    Location
    New York, NY, U.S.
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm still getting the errors. I changed the code but also added a few things. And I cannot get my code to INSERT into the database table.

    PHP Code:
    <?php
    //Database access
    $dbh = @mysql_connect("localhost""admin""balls") OR die ('Could not connect: ' mysql_error());
    @
    mysql_select_db ('dexdog') OR die ('Could not select database: ' mysql_error());

        
    // Define Constants
        
    define ("FILEREPOSITORY","C:\\Program Files\\Web Design\\wamp\\www\\dexdog\\photos\\");
        
        
    //Check if file was posted
        
    if(is_uploaded_file($_FILES['photo']['tmp_name'])) {
          
            
    //Check to see if file was a photo/picture
            
    if(($_FILES['photo']['type']) != ('image/jpeg' || 'image/gif' || 'image/bmp')){
                echo 
    "<p>Photos must be JPG/JPEG, GIF, or BMP file formats please, most digital cameras will take pictures in JPG/JPEG format. If your camera takes pictures in TIFF or another format not currently supported by this site, please contact us and we will try to help remedy the problem. Thank you.</p>";
                
                } else { 
    //Move file to destination
                    
    $ownername $_POST['ownername'];
                    
    $dogname $_POST['dogname'];
                    
    $location $_POST['location'];
                    
                    echo 
    "$ownername <br />";
                    echo 
    "$dogname <br />";
                    echo 
    "$location <br />";
                    
                        
    $query "INSERT INTO photos (owner, dog, location, photo, reg_date) VALUES ($ownername$dogname$location, NULL, NOW())";
                        
    $result mysql_query($query);
                    
                    if(
    $_FILES['photo']['type'] == "image/jpeg"){
                        
    $result move_uploaded_file($_FILES['photo']['tmp_name'],FILEREPOSITORY."\\" $dogname ".jpg");
                    } elseif(
    $_FILES['photo']['type'] == "image/gif") {
                        
    $result move_uploaded_file($_FILES['photo']['tmp_name'],FILEREPOSITORY."\\" $dogname ".gif");
                    } else {
                          
    $result move_uploaded_file($_FILES['photo']['tmp_name'],FILEREPOSITORY "\\" $dogname ".bmp");
                    }
                    if(
    $result == 1){ //check if file was moved successfully
                        
                        
    $query NULL;
                        
    $query "SELECT * FROM photos";
                        
    $result mysql_query($query);
                        
                        while (
    $row mysql_fetch_array($resultMYSQL_NUM)){
                          echo 
    "$row[0]$row[1], ****!";}
                        
                            echo 
    "<p>successfully uploaded.<p/>";
                        } else { 
                            echo 
    "<p>Encountered a problem uploading the file.</p>";
                        }
                    }
            }
    ?>
    I'd like to figure out how to use PEAR modules like MDB2 to protect my databases/SQL injections. Thanks for any info you can give, and I appreciate the help thus far. Thanks.

  21. #21
    SitePoint Addict evertcollab's Avatar
    Join Date
    Apr 2006
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That error kind of looks like a macromedia flash error...

  22. #22
    SitePoint Zealot
    Join Date
    Dec 2005
    Location
    New York, NY, U.S.
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It appears as though the unresponsiveness of the script is due to the size of the file. I checked a 1.12 MB file and a 7.88 KB file. The latter had no troubles. Any ideas how I could allow the bigger files to not be so rough on the script? or just take longer to load instead of causing the script error?

  23. #23
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    Romania, Iasi
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That happens to me in firefox whenever i upload something to gmail, imageshack or any other site that allows uploads on big files. If i click continue.. nothing happens... if i click stop script then everything goes as intended. I presume it's from either firefox itself (wich i doubt) or one of the extensions (noscript most likely).

  24. #24
    SitePoint Zealot
    Join Date
    Dec 2005
    Location
    New York, NY, U.S.
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I get that in gmail also, however I do not have no script as an extension.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •