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
Zoram
Forum Contributor
Posts: 166 Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:
Post
by Zoram » Sun Oct 20, 2002 10:23 pm
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?
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Sun Oct 20, 2002 10:46 pm
change move_uploaded_file() to copy() -- see if it works
than just call unlink() to delete the tmp file
Zoram
Forum Contributor
Posts: 166 Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:
Post
by Zoram » Sun Oct 20, 2002 10:57 pm
nothing. It doesn't work with the copy()
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Sun Oct 20, 2002 11:22 pm
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');
...
Zoram
Forum Contributor
Posts: 166 Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:
Post
by Zoram » Sun Oct 20, 2002 11:38 pm
It's still not doing anything. I don't get it.