Announcement

Collapse
No announcement yet.

problem in downloading file...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem in downloading file...

    hi...

    i have this folder called files... and this folder is protected by the htaccess file...

    i have created a normal download script, just a button and the button point to a file in the files folder... so, when i accessed the script, i have a login screen prompting to enter the username and password to access the folder...

    so, is there any way that i can bypass this login screen by putting the username and the password in the download script... hidden from the user...

    thanx for the help...

  • #2
    Hidden from the user? No. You can point the form / button at http://username[email protected]/files/file.wht.
    Chen Avinadav
    Better to remain silent and be thought a fool than to speak out and remove all doubt.

    גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

    Comment


    • #3
      can i use the variables $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] for the authentication...

      and any comment on this:
      $path = "files/myfile.zip";
      $filename = basename( $path );
      header( "Content-Disposition: attachment; filename=$filename" );
      readfile( $path );
      i found this code during my search for the problem... it said that it can bypass the htaccess file and read the file into the browser and force the download dialog box to pop up...

      thanx for the help...

      Comment


      • #4
        You MUST use these variables if you want to do with PHP.

        The code is ok, but you want to send a content-type header to make it easier for the downloader. Go to phpBB or iBF and see how they serve an attachment.
        Chen Avinadav
        Better to remain silent and be thought a fool than to speak out and remove all doubt.

        גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

        Comment


        • #5
          i'm sorry cause the download script was done in php... so, the variables can be use...

          can you show me an example... on how to pass the variables to the page... please...

          and the content type, can i put as unknown... since the files can be anything...

          thanx a lot...

          Comment


          • #6
            You can send unknown/unknown, but then if it's an image the user will need to download it and won't be able to view it in the browser.
            Chen Avinadav
            Better to remain silent and be thought a fool than to speak out and remove all doubt.

            גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

            Comment


            • #7
              it works fine... and here is the code:
              $downloadpath = "files/" . $HTTP_POST_VARS["filename"];
              download($downloadpath);

              function download($path) {
              $filename = basename($path);

              header("Content-Type: application/mac-binhex40");
              header("Content-Disposition: filename=$filename");
              readfile($path);
              }
              if i want to put the type as unknown... the code should look like this,
              header("Content-Type: unknown/unknown");

              ok... now, the problem is that it works fine on IE... but in Netscape 6/6.2, it won't work... can anyone explain... please...

              thanx a lot...

              Comment

              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
              Working...
              X