Re: [NEWBIE] Trying to create a function from an existing script

From: Date: Fri, 28 Jan 2005 05:59:03 +0000
Subject: Re: [NEWBIE] Trying to create a function from an existing script
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-207549@lists.php.net to get a copy of this message
basename is looking for a file and $HTTP_POST_FILES[$name]['name'] is not a valid path to a file. Something like this should work if(move_uploaded_file($_HTTP_POST_FILES['upfile']['tmp_name'], rawurlencode($store_dir.$HTTP_POST_FILES['upfile']['name'])) On Fri, 2005-01-28 at 14:41 +0900, Dave wrote: > Marek, Mark, > Thanks for the advice. I've added "global $HTTP_POST_FILES;" into my > function, and it is working. > I'd also like to follow Marek's advice to modify my script, as it > sounds like it helps to make it more secure. However, I don't think I'm > using the syntax right. I changed: > > if( > > copy($HTTP_POST_FILES['upfile']['tmp_name'],$store_dir.$HTTP_POST_FILES['upfile']['name']) > > to > > if ( move_uploaded_file($HTTP_POST_FILES[$name]['tmp_name'], $store_dir > . basename($HTTP_POST_FILES[$name]['name']) ) > > ... because I looked up move_upload_file() in the manual, and it says it > will return FALSE if it fails, so I thought I could encase it in an if() > statement. But it's always returning false and not uploading the file. > Have I got it wroing? > > -- > Dave Gutteridge > dave@tokyocomedy.com >

« previous php.general (#207549) next »