Page 1 of 1
File Upload Problem
Posted: Sun Oct 20, 2002 10:23 pm
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?
Posted: Sun Oct 20, 2002 10:46 pm
by hob_goblin
change move_uploaded_file() to copy() -- see if it works
than just call unlink() to delete the tmp file
Posted: Sun Oct 20, 2002 10:57 pm
by Zoram
nothing. It doesn't work with the copy()
Posted: Sun Oct 20, 2002 11:22 pm
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');
...
Posted: Sun Oct 20, 2002 11:38 pm
by Zoram
It's still not doing anything. I don't get it.