vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Question regarding fwrite(), filesize(), binary stream (https://vborg.vbsupport.ru/showthread.php?t=65307)

lierduh 05-20-2004 01:54 AM

Question regarding fwrite(), filesize(), binary stream
 
I have the stream of the binary data. I need to use some file
associated function with it. For example filesize(), imagesize() etc.
At the moment, I write this data stream into a tmp file
fwrite('/tmp/tempfile', 'x+'), do the file functions, then unlink()
it. It surely is not an elegant way to do, let along a good
portability way.

Is there a way to create a file in the memory from the data stream? or
even use file functions without first write the stream into a file?
Thanks.

Velocd 05-20-2004 10:03 PM

To get information about a file, without saving it to a permanent directory:

PHP Code:

$file $_FILES['file_input']['tmp_name'];  // uploaded file to temporary directory on server
$file_size $_FILES['file_input']['size']; 

If this file was an image, you could also:

PHP Code:

if (strpos($_FILES['userfile']['type'], 'image'))
    
$dimensions = @getimagesize($file); // returns array, index 0 = width, index 1 = height 


lierduh 05-20-2004 10:32 PM

Quote:

Originally Posted by Velocd
To get information about a file, without saving it to a permanent directory:

Velocd, thanks for the reply.:)

Unfortunately this data stream does not come from a uploaded file. It is actually from decoded mime/uuencoded message.

May be I can find the temp directory enviroment within the script.

lierduh 05-22-2004 06:45 AM

I have found you can actually write to $_FILES.:)

Also to find out the temp direcotory. The following code should help:

if (!$tmp_dir = get_cfg_var('upload_tmp_dir')) {
$tmp_dir = dirname(tempnam('', ''));
}


All times are GMT. The time now is 06:22 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02175 seconds
  • Memory Usage 1,723KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete