01292006 1229 GMT-6 Im working on that same thing. I did notice a filesize() function but you have to pass the name as a string to filesize(). If you do not the stat will not start. Check out this code from:
http://www.phpfreaks.com/print.php?cmd=tutorial&tut_id=85 |<?php function get_file_size() { //SECTION #1 $temp_file_name = trim($this->temp_file_name); $kb = 1024; $mb = 1024 * $kb; $gb = 1024 * $mb; $tb = 1024 * $gb; //SECTION #2 if ($temp_file_name) { $size = filesize($temp_file_name); if ($size < $kb) { $file_size = "$size Bytes"; } elseif ($size < $mb) { $final = round($size/$kb,2); $file_size = "$final KB"; } elseif ($size < $gb) { $final = round($size/$mb,2); $file_size = "$final MB"; } elseif($size < $tb) { $final = round($size/$gb,2); $file_size = "$final GB"; } else { $final = round($size/$tb,2); $file_size = "$final TB"; } } else { $file_size = "ERROR: NO FILE <http://www.phpfreaks.com/phpmanual/page/function.file.html> PASSED TO get_file_size()"; } return $file_size; } ?> Wade | Marian Briones wrote: >I had $_FILE[yadda] instead of $_FILES[yadda] > >Banging head on desk > >--- In [email protected], "Marian Briones" <[EMAIL PROTECTED]> wrote: > > >>Well, I latched onto the size value of the upload and figured okay, if >>the value is greater than 0, then process the file >> >>if ($_FILE['pageimage']['size']==0) >>{ >> $processimage="no"; >> $imageinsert="$oldimage"; >>} >>else >>{ >> $processimage="yes"; >>} >> >>But guess what? >> >>IT STILL DOESN'T WORK! It won't even process the image now even >>though the size is greater than 0! >> >>I am stumped >> >>PS James, thank you for your great info here. This particular area >>is only available to site administrators with passwords. >> >>--- In [email protected], James Keeline <[EMAIL PROTECTED]> wrote: >> >> >>>--- Marian Briones <[EMAIL PROTECTED]> wrote: >>> >>> >>> >>>>I posted yesterday and no one answered; I"m wondering if this >>>>list is having tech difficulties.... >>>> >>>> >>>Your message came through but perhaps people were busy. I know I >>> >>> >>was (and still am). However, to >> >> >>>briefly address your question I offer the following. >>> >>>Like $_POST and $_GET, $_FILES is a superglobal which is intended to >>> >>> >>collect information received >> >> >>>from a particular input stream. In this case, the $_FILES contains >>> >>> >>data relevant to uploaded >> >> >>>files. >>> >>>This associative array has a first key which corresponds to the name >>> >>> >>of the variable in your >> >> >>>upload form. In the example below, the name of the uploaded file is >>> >>> >>myfile so the portion of the >> >> >>>array is $_FILES['myfile']. >>> >>><form method='post' action='script.php' enctype='multipart/form-data'> >>><input type='file' name='myfile'> >>><input type='submit'> >>></form> >>> >>>You should make a test script with a simple form and in the PHP >>> >>> >>which is identified in the action >> >> >>>parameter of the form tag you can display the variables available >>> >>> >>during your upload: >> >> >>><pre> >>>The $_FILES array contains: >>><?php print_r($_FILES); ?> >>></pre> >>> >>>When a file is uploaded you will see the following values: >>> >>>$_FILES['myfile']['name'] // name of the original file >>>$_FILES['myfile']['size'] // size in bytes of the file >>>$_FILES['myfile']['type'] // MIME type of the file >>>$_FILES['myfile']['tmp_name'] // path to temporary file >>>$_FILES['myfile']['error'] // error code (0=no error) >>> >>>You will have to consult one of these specific values to see if your >>> >>> >>file was uploaded. Keep in >> >> >>>mind that several of these values may not be trustworthy. For >>> >>> >>example, the MIME type could be >> >> >>>faked by the uploading computer so use a server-based verification >>> >>> >>that the item is really an >> >> >>>image (such as the getimagesize() function). >>> >>>File uploads are very risky if not handled carefully. You are >>> >>> >>basically allowing unknown web >> >> >>>users the ability to place files of any type on your server. Two >>> >>> >>newer functions were added to >> >> >>>PHP to help ensure that the data you think is a file was an actual >>> >>> >>upload: >> >> >>>http://www.php.net/is_uploaded_file >>>http://www.php.net/move_uploaded_file >>> >>>They should be used instead of the old copy() and unlink() method >>> >>> >>seen in old tutorials and >> >> >>>scripts on file uploads. There is also good information on: >>> >>>http://us3.php.net/manual/en/features.file-upload.php >>> >>>James >>>_____ >>> >>> >>>James D. Keeline >>>http://www.Keeline.com http://www.Keeline.com/articles >>>http://Stratemeyer.org http://www.Keeline.com/TSCollection >>> >>>http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc. >>>Fall Semester Begins Sep 7 -- New Classes Start Every Few Weeks. >>>Spring Semester Begins in late January. Two new class topics. >>> >>> >>> > > > > > > >Community email addresses: > Post message: [email protected] > Subscribe: [EMAIL PROTECTED] > Unsubscribe: [EMAIL PROTECTED] > List owner: [EMAIL PROTECTED] > >Shortcut URL to this page: > http://groups.yahoo.com/group/php-list >Yahoo! Groups Links > > > > > > > > > > [Non-text portions of this message have been removed] Community email addresses: Post message: [email protected] Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
