File Upload Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

File Upload Problem

Post by Zoram »

Code: Select all

<?php
if(!is_dir ("images/Contests")) die('merde');

$imgDir = 'images/Contests'; // Image Directory

			if (isset($_FILESї'userfile'])) 
			 { 
				  $pos = strrpos($_FILESї'userfile']ї'tmp_name'], '/'); 
				  if ($pos < strrpos($_FILESї'userfile']ї'tmp_name'], '\''))      // annoying bug 
					   $pos = strrpos($_FILESї'userfile']ї'tmp_name'], '\'');          // under win32 :-S 
				  $filename = substr($_FILESї'userfile']ї'tmp_name'], $pos);  // filename without path 
				   
				  $bFileUpload = move_uploaded_file($_FILESї'userfile']ї'tmp_name'], $imgDir.$filename);  
				  $filename = mysql_escape_string($filename); 
			 }
?>
That is what i have. I can't get it to move the file. Anyone help?
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

change move_uploaded_file() to copy() -- see if it works

than just call unlink() to delete the tmp file
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

Post by Zoram »

nothing. It doesn't work with the copy()
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you're sure it enters the if (isset($_FILES['userfile'])) block and 'only' $bFileUpload is ==FALSE?

Code: Select all

if(!is_dir ("images/Contests")) die('directory does not exist');
if(!is_writable("images/Contests")) die('no write permissions');

...

$bFileUpload = move_uploaded_file($_FILESї'userfile']ї'tmp_name'], $imgDir.$filename) or die($_FILESї'userfile']ї'tmp_name'] . '--> '. $imgDir.$filename . ' failed');

...
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

Post by Zoram »

It's still not doing anything. I don't get it.
Post Reply