php-windows Digest 4 Nov 2005 23:15:26 -0000 Issue 2813

Topics (messages 26457 through 26460):

Re: list files in a directory
        26457 by: Jay Blanchard

list files in directory
        26458 by: JC Botha

Pls Help Needed  I am new toPHP
        26459 by: kumar kumar

PHP 5.0 and MySQL Support
        26460 by: G. Eggold

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
[snip]
I got some directories on a web server, these I called with PHP to be
displayed on an HTML page. But I do not get them sorted properly. I want
them to be sorted by name and not by size. Could some one please shed some
light on this.
[/snip]

Get all of the directory or file names into an array and then sort the
array.

--- End Message ---
--- Begin Message ---
Thanks for all your help and advice. I did struggle with the array part but
got it worked out. Perhaps you could have a quick look at the script and let
me know if it is stable enough.

 

<?php

 

function disfile($dir, $file, $num, $status)

{

            /*

            $filelocation = $dir.$file;

            if(is_file($filelocation))

            {

            $filesizefile = filesize($filelocation);

            if($filesizefile >  1048575)

            {

            $filesizefile = round(($filesizefile/1024)/1024, 1);

            $term = "Mb";

            } elseif ($filesizefile < 1024) {

            $filesizefile = round(($filesizefile), 1);

            $term = "bytes";

            } else {

            $filesizefile = round(($filesizefile/1024), 1);

            $term = "Kb";

            }

            }

            */

            $filelength = strlen($file);

            $disfile = substr($file, 0, ($filelength -3));

            if($status == 'true')

            {

                        $file_link .= "<INPUT TYPE=RADIO NAME=\"file_name\"
VALUE=\"$dir$file\"> $disfile<br>";

            }else{

                        $file_link .= "<li> <a href=\" $dir$file\"
target=\"_blank\">" . $disfile . "</a></li>";

                        //<font size=1>($filesizefile $term)</font><br>";

            }

            return $file_link;

}

function download($dir,$ms)

{

            if (isset($_GET['download']))

            {

                        header("Content-Type: octet/stream");

                        header("Content-Disposition: attachment; filename="
. basename($_GET['download']));

                        //echo file_get_contents($_GET['download']);

            } else {

                        if ($open = opendir($dir))

                        {

                                    $num = 0;

                                    $filenames = Array();

                                    while (false !== ($file =
readdir($open)))

                                    {

                                                if ($file != "." && $file !=
"..")

                                                {

 
$filenames[]=$file;

                                                            if (!is_dir($dir
. $file))

                                                            {

                                                                        $num
++;

                                                            } 

                                                }

                                    }

                                    sort($filenames);

                                    $cout = count($filenames);

                                    for ($i = 0; $i < $cout; $i++)

                                    {

                                                $folder_files .=
disfile($dir,$filenames[$i],$num,$ms);

                                    }

                        }

                        closedir($open);

            }

            return $folder_files;

}

?>


--- End Message ---
--- Begin Message ---
hi 

how to get the byte stream in php 

like in JSP i am using this code  in JSP

<%
 
        try{
  ServletInputStream in = request.getInputStream();
  byte[] line = new byte[8192];
  int bytes = 0;
  FileOutputStream fileOutS = new 
FileOutputStream(fileOut);

  while(0 <(bytes = in.read(line))){
     fileOutS.write(line,0, bytes);
                          
   }
             
 fileOutS.close();
 fileOutS = null;
out.println("SUCCESSFUL : Upload Stream Saved to \"" +
fileOut + "\".");
 }catch(Exception e){
 out.println("ERROR : Exception \"" + e.getMessage() +
"\" Occured.");
    }
%>


now i have to write the same fuctionality in PHP


i tried the following code  it is also not a solution
for my problem

$request  =  new Java("javax.ServletRequest",$req);
$request -> getInputStream();
                 
$in =    $new
Java("javax.servlet.ServletInputStream",$in);

 $byte[] =  new Java("java.lang.byte",$line);
  
                  $bytes = 0;
                        
 new Java("java.io.FileOutputStream", $fileOutS)
                        
                  $fileOutS = new Java(
FileOutputStream($dir$file));

   while(0 <($bytes = in ->read($line))){
                  
  $fileOutS->write($line,0, $bytes);

                          }             

but i have to write  it with out using java extension
in PHP    

i am new to php . Your Help is appreciated

Thanking You
Regards 
Kumar


        
                
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

--- End Message ---
--- Begin Message ---
I've read a LOT of posts talking about the problems others are having
getting PHP 5 and MySQL to play nice with each other on Windows boxes.  I've
now found myself in the same boat, drifting aimlessly thru a sea of ^%$#.

I'm running PHP 5.0.5 on the Win03 server with MySQL 4.1.15

PHP is working fine, but I can't get a connection to MySQL working.  The
first symptom is that the MySQL "section" is not showing up in the phpinfo()
listing. The second symptom is the failure of the following code line:
$db = @MYSQL_CONNECT($db_server,$db_user,$db_password) or die ("Cannot
connect to database");

with NO ERROR message.  Despite reading tons of newgroup and forum posts,
I've not found the solution.

* The "extensions" for mysql and mysqli are uncommented in php.ini.
extension=php_mysql.dll
extension=php_mysqli.dll

* My PATH environment var is correctly set (c:\php5)
* the proper DLLs are in c:\php5
* the extension_dir config param is [un-necessarily] set to C:\PHP5 just to
be safe.

Has anyone out there solved this same problem?  Other suggestions?

Greg E.

--- End Message ---

Reply via email to