Results 1 to 7 of 7

Thread: Firefox problem with perl script

  1. #1
    Join Date
    Jan 2010
    Posts
    311

    Firefox problem with perl script

    Hello,
    I use a perl script to fetch the variables of a form to then execute the applications using the DBI module for perl. But I have a small problem with Firefox at this level:

    Here is my code
    Code:
    ###### Creating the html file back to the execution of perl script
    print "Content-type: text / html \ n \ n";
    print "<html> <head> <link rel='stylesheet' href='../public_html/test.css' type='text/css'> </ head> \ n";
    print "<body> <h1> Verification inclusion </ h1> \ n";
    print "<br> \ n";
    print "<form method='post' action='pagename'> \ n";
    print "<input type='submit' value='Retour'> </ form> \ n";
    print "foo \ n";
    print "</ body> </ html> \ n";

    In Internet Explorer, my html page is displayed correctly, the browser Comprises the html code, while in firefox, it does not bind the code, it just displays. Is there a problem with firefox and this type of use? How to solve this problem?

  2. #2
    Join Date
    May 2008
    Posts
    248

    Re: Firefox problem with perl script

    You must indicate the type of document you sent. The top of your scrip, the first print must be:
    Code:
    print "Content-Type: text / html \ n \ n";
    Just add it to to your script or you can even modify your or replace your script by the following line of code.

  3. #3
    Join Date
    Mar 2010
    Posts
    162

    Re: Firefox problem with perl script

    This is the code you are looking for

    Code:
    use testcgi (qw: standard);
    use str;
    my $ testcgi = new testcgi;
    print $ testcgi-> header ();
    print $ testcgi-> start_html (-title => 'page title'
                           -Style => '.. / public_html / leptostyle.css');
    print $ testcgi-> h1 ('Verification of integration'), $ testcgi-> br ();
    print $ testcgi-> START_FORM (-name => 'name of the form'
                            -Method => 'post'
                            -Action => '.. / public_html / index.php? Page = insert');
    print $ testcgi-> submit (-name => 'button',-value => 'Back');
    print "foo \ n";
    print $ testcgi-> END_FORM (), $ testcgi-> end_html ();

  4. #4
    Join Date
    Nov 2009
    Posts
    330

    Re: Firefox problem with perl script

    Your question is not a problem with HTML and PERL. Your HTML script is full of errors, such as unfinished form, no title page, no form name, and the header does not seem to me correct. In any HTML page, rather I see a header like:
    Code:
    <! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN">
    Change this in your code and run a test on it.

  5. #5
    Join Date
    Jan 2010
    Posts
    311

    Re: Firefox problem with perl script

    Thanks for your replies, another question, can I use PHP instead of HTML? Because in fact, I have a html page consists of a form and a field to upload a file. When I validate my form, I run my perl script that retrieves the variables from my form. After treatment of my variables, my script needs then the file I uploaded. Before I use a php page to process the upload:
    Here is my code
    Code:
    <Php
    / / In PHP 4.1.0, $ HTTP_POST_FILES should be used
    / / Instead of $ fls.
    $ updri = 'C: \ Program Files \ EasyPHP1-8 \ www \ public_html \ upload \ \';
    $ = $ upfl updri. basename ($ fls ['userfile'] ['name']);
    echo '<pre>';
    if (move_uploaded_file ($ fls ['userfile'] ['tmp_name'], $ upfl)) (
       echo "File is valid, and has been downloaded
               successfully. Here is more info: \ n ";
    ) else (
       echo "potential attack by downloading files.
             Here is more info: \ n ";
    )
    / / Echo 'Here is some debug info:';
    / / Print_r ($ fls);
    echo '</ pre>';
    ?>

  6. #6
    Join Date
    Dec 2009
    Posts
    192

    Re: Firefox problem with perl script

    Why do you manage does not upload directly into your PERL script? To manage the upload, you must:

    1. Declare the HTML form in "multipart", with the following line:

    Code:
    print $ testcgi-> start (-method => "POST",
                                          -Action => "test.pl"
                                          -Name => "ifroumla");
    2. Declaring a field for the user to define the import file:
    Code:
    Code:
    print $ testcgi-> FileField (-name => 'dumpdata',-size => 50);
    (There are other properties available, I think In particular with a filter extensions it seems to me)

    3. Recover the file if the user submitted the form with its roster set:
    Code:
    if ( defined \ $ testcgi-> param ('testing code'))
    (
       my $ f_hd = $ testcgi-> param ('testing code');
       while (<$ f_hd>)
       (
          chomp;
          # Manage data read
       )
    )

  7. #7
    Join Date
    Nov 2009
    Posts
    347

    Re: Firefox problem with perl script

    You can use this

    Code:
    use CGI:: Upload;
         my $ upld = CGI:: Upload->new;
         my $ flnm = $ upld-> flnm ('field');
         my $ file_type = $ upld-> file_type ('field');
         $ Upload-> mime_magic ('/ path / to / mime.types');
         my $ mime_type = $ upld-> mime_type ('field');
         my $ upld = $ file_handle-> file_handle ('field');

Similar Threads

  1. How to run Perl script on Mozilla Firefox?
    By Grayson in forum Software Development
    Replies: 5
    Last Post: 02-11-2011, 02:35 PM
  2. How to call perl script from Python?
    By Jhonwho in forum Software Development
    Replies: 3
    Last Post: 23-07-2009, 09:59 PM
  3. Is it possible to execute Perl script within another script?
    By RasMus in forum Software Development
    Replies: 2
    Last Post: 21-07-2009, 10:57 PM
  4. Need Perl script to execute from another.
    By beelow in forum Software Development
    Replies: 2
    Last Post: 20-06-2009, 09:17 AM
  5. Title of a Perl CGI script
    By !const in forum Software Development
    Replies: 2
    Last Post: 26-03-2009, 11:43 PM

Tags for this Thread

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
  •  
Page generated in 1,711,614,530.87641 seconds with 17 queries