×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    28

    Force dowload of .py file

    Hello. I´m absolutely new as web designer for mobile phones and I have some doubts how to start.

    First I need is know how to force the download of a file with extension .py, instead of open it with the browser as a textpage.
    I have that code in PHP that works in IE at PC, but not in my NokiaE65. I´d like to know why.

    Thank you very much


    PHP Code:
    <?php
        $extensiones 
    = array("py"); // extensiones que permitiremos
        
    $f $_GET["f"];
        if(
    strpos($f,"/")!==false){
            die(
    "No puedes navegar por otros directorios");
        }
        
    $ftmp explode(".",$f);
        
    $fExt strtolower($ftmp[count($ftmp)-1]);
     
        if(!
    in_array($fExt,$extensiones)){
            die(
    "<b>ERROR!</b> no es posible descargar archivos con la extensión $fExt");
        }
     
        
    header("Content-type: application/octet-stream");
        
    header("Content-Disposition: attachment; filename=\"$f\"\n");
        
    $fp=fopen("$f""r");
        
    fpassthru($fp);
    ?>

  2. #2
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,777

    Re: Force dowload of .py file

    Do you use the default Nokia browser or Opera ? Or ay other?

    Br,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    28

    Re: Force dowload of .py file

    Default browser. Both nokia e65 an emulator, both the same result, it opens the script as text in the browser

  4. #4
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,777

    Re: Force dowload of .py file

    Quote Originally Posted by totetote View Post
    Default browser. Both nokia e65 an emulator, both the same result, it opens the script as text in the browser
    I had some problems with it too. A work around I used was to have the .py script files zipped.

    I had one of the browsers working to download the file instead of opening as text. I guess it would have been opera or Ucweb.

    Best Regards,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  5. #5
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Force dowload of .py file

    Quote Originally Posted by totetote View Post
    Default browser. Both nokia e65 an emulator, both the same result, it opens the script as text in the browser
    hi totetote
    you can download the .py file using opera i tried it. and your php code will not work as the browser of phone is widely different from that of a PC.

  6. #6
    Registered User
    Join Date
    Feb 2008
    Posts
    28

    Re: Force dowload of .py file

    I´ll try installing and using opera for mobile.

    BTW. Doesnt have the default browser a "save as" or something?

  7. #7
    Registered User
    Join Date
    Feb 2008
    Posts
    28

    Re: Force dowload of .py file

    Quote Originally Posted by gaba88 View Post
    hi totetote you can download the .py file using opera i tried it. and your php code will not work as the browser of phone is widely different from that of a PC.
    Ok i tried opera and as you said it downloads the file. Buuut, the file downloaded is "like corrupted" and i cant neither with python neither with the default "noteviewer".

    What I´m doing wrong?

  8. #8
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Force dowload of .py file

    hi totetote
    you are not doing anything wrong same thing is happening with me. i am only able to see and read the .py script cant do anything else.

  9. #9
    Registered User
    Join Date
    Feb 2008
    Posts
    28

    Re: Force dowload of .py file

    Then I think I have an unsolvable problem. I´ll have to make my page for PC and then make my users transfer the files to the mobile.
    Thanks a lot for helping.

  10. #10
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Force dowload of .py file

    Quote Originally Posted by totetote View Post
    Then I think I have an unsolvable problem. I´ll have to make my page for PC and then make my users transfer the files to the mobile.
    Thanks a lot for helping.
    hi totetote
    really sorry but i think you have to do that until somebody comes up with a solution.

  11. #11
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,777

    Re: Force dowload of .py file

    Quote Originally Posted by totetote View Post
    Then I think I have an unsolvable problem. I´ll have to make my page for PC and then make my users transfer the files to the mobile.
    Thanks a lot for helping.
    Just to be more specific, which version did you use, Opera browser or Opera mini browser ?

    Br,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  12. #12
    Registered User
    Join Date
    Feb 2008
    Posts
    28

    Re: Force dowload of .py file

    Quote Originally Posted by croozeus View Post
    Just to be more specific, which version did you use, Opera browser or Opera mini browser ?

    Br,
    Croozeus
    I tried some new things and:


    Default Browser = No download.
    Opera Mobile for S60, version 8.65. It downloads the file "corrupted"
    Opera Mini 4.1. It downloads the file perfect.

  13. #13
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,777

    Re: Force dowload of .py file

    Quote Originally Posted by totetote View Post
    Opera Mini 4.1. It downloads the file perfect.
    Yes, thats what I use.

    Workaround for other browsers would be to have the script zipped.
    Unconventional but works with other browsers as well !

    Br,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

Similar Threads

  1. PED and signing.
    By IX in forum Python
    Replies: 11
    Last Post: 2008-04-21, 01:15
  2. Problem with ensymble_python2.5-0.26.py in linux
    By tansualpcan in forum Python
    Replies: 2
    Last Post: 2008-04-15, 10:12
  3. [announce] PyUIQ. Python for UIQ 2.1 and 3.x
    By OscarBernabeu in forum Python
    Replies: 35
    Last Post: 2008-01-17, 09:12
  4. Contacts fields order??
    By timatima in forum Symbian C++
    Replies: 1
    Last Post: 2007-06-08, 13:51
  5. How to create mbm file?
    By qt_raip in forum Symbian Tools & SDKs
    Replies: 13
    Last Post: 2004-05-12, 11:07

Posting Permissions

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