Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2004032

[PHP] file super global and functions From: Bruno Santos (brvds <email protected>)
Date: 03/31/04

hello all

i've a problem, serious one.

how can i pass the name of a file upload to a function ?

i need to do the upload of 1 file, but want to use a function, so that
the main file stays small

the problem is, when passing the file name, throw the $_FILES super
global , is not recognized in the function...

here is the code:

############ the function (or part of it)

function uploadfile ($userfile, $name2file,$uploadir) {
        //userfile is where file went on webserver
        echo 'inside'; <<< ---- debuging purpose
        $userfile = $_FILES['userfile']['tmp_name'];

        //userfile_name is original file name
        $userfile_name = $_FILES['userfile']['name'];

        echo 'User File name: '.$userfile_name; <<< --- debuging purpose

############## main program ##################33

uploadfile
($_FILES['user_picture'],$_SESSION['valid_user'].'_picture',$USERPICS);

this is the call to the function above

the problem is that inside the function, the file name is not recognized...
when i try to print the filename, is empty ....

any ideas ????

it only works if $_FILSE['user_picture'] is $userfile ......

should i pass the values by reference ?i mean, putting some sort of & ??

cheers and best regars

Bruno

-- 
-----------------------------------------------------
	       .-'''''-.
              .'         `.
             :             :
            :               :
            :      _/|      :       Bruno Santos
             :   =/_/      :     brvds <email protected>
              `._/ |     .'
           (   /  ,|...-'        Pagina Pessoal
            \_/^\/||__   http://feiticeir0.no-ip.org
         _/~  `""~`"` \_
      __/  -'/  `-._ `\_\__
    /jgs  /-'`  `\   \  \-.\

"Written very small on the back poket of a girl's jeans - 'If you can read this, you're WAY too close.'"

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