tags:

views:

81

answers:

3

I have a PHP page(registration.php) from where i would submit a file to another form(preocess.php) .So that in the next page that page will send that file as an attachment to an email id. Can i Call a function in another file and pass this file to that function ? It is some think like passing a stream to a function. (I am not sure .) Can anyone guide me on this ?

A: 

Absolutely, just include the file that originally calls the function.

<?php include ('file_with_function.php'); ?>
Tyler Rash
A: 

Should not pass a file around, better to handle it in the background.

  • store the file
  • put some id (in worst case the path) into session
  • forward the user to the next step (process.php)

Better yet to review and refactor the code if necessary to make the processing in one step. This way you can avoid half-processed things, entry to the processing pipeline in the middle and similar common multi-page form handling problems.

Csaba Kétszeri
A: 

If you're trying to email the file to someone, PHPMailer (http://phpmailer.codeworxtech.com/index.php?pg=methods) has a function addAttachment that works really well.

If you're just trying to process the file in some way, file_get_contents will get the content of the file as a string, which can be useful if it's text. You do, however, need to be careful that it's a small file, otherwise you'll run out of memory pretty quickly.

Chris Henry