Re: two confuse problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, August 8, 2007 1:43 am, EVEL_LIU@xxxxxxxxxxx wrote:
> As the follow show:
>
> I want to meet a function that,
>
> 1,Click the brows bottom, and select one file, return the file name to
> the text area and the file¡¦s size to the $filesize.
>
> I don¡¦t how to make the browser bottom to achieve that.?

When you upload a file, after it is uploaded, PHP has the filesize.

Before you upload it, PHP isn't even *IN* the picture frame, so you
must be talking about Javascript, so you're in the wrong place.

Unless, of course, the PHP script, the file, the browser, the server,
the client, are all just one machine...

http://php.net/filesize

> 2,use the zip_read function of the PHP: ¡]because most of the file
> type is *.zip and *.doc¡^



> The file name will be return by a name filter function.
>
> <?php
>
>
>
> $zip = zip_open("test.zip");
>
>
>
> if ($zip) {
>
>     while ($zip_entry = zip_read($zip)) {
>
>         echo "Name:               " . zip_entry_name($zip_entry) .
> "\n";
>
>         echo "Actual Filesize:    " . zip_entry_filesize($zip_entry) .
> "\n";
>
>         echo "Compressed Size:    " .
> zip_entry_compressedsize($zip_entry) . "\n";
>
>         echo "Compression Method: " .
> zip_entry_compressionmethod($zip_entry) . "\n";
>
>
>
>         if (zip_entry_open($zip, $zip_entry, "r")) {
>
>             echo "File Contents:\n";
>
>             $buf = zip_entry_read($zip_entry,
> zip_entry_filesize($zip_entry));
>
>             echo "$buf\n";
>
>
>
>             zip_entry_close($zip_entry);
>
>         }
>
>         echo "\n";
>
>
>
>     }
>
>
>
>     zip_close($zip);
>
>
>
> }
>
> ?>
>
> Error information:
>
> Warning: zip_read() expects parameter 1 to be resource, integer given
> in D:\www¡Kon line 6

You didn't check the return value of zip_open.

It wasn't able to open the zip file.

Everything else falls out from that.

Write more error-checking code.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux