[SOLVED] -> copy file upload
Posted: Fri Jun 18, 2004 5:50 pm
my error, tried differant things here, might have screwed up some more, but all i get now is the following error
Any help apreciatedcopy(Apache/htdocs/files/062004/18214354-952.image/gif): failed to open stream: No such file or directory in 48
This is ofcourse the copy part
Code: Select all
$uploaddir = 'Apache/htdocs';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
$time = time();
#$dir = date("mY/$time");
$dir = date("mY", $time);
if (!is_dir($uploaddir.'/files/'.$dir))
{
umask(0);
mkdir ("files/".$dir, 0777);
}
if ($userfile_type == 'image/gif') {
$type = '.gif';
}
if ($userfile_type == 'image/pjpeg') {
$type = '.jpg';
}
if ($userfile_type == 'image/x-png') {
$type = '.jpg';
}
$fileb = date("dHis", $time);
$filee = rand(0, 999);
$fn = $fileb."-".$filee;
$pic = "/files/".$dir."/".$fn.".".$userfile_type;
$intpic = $dir."/".$fn.".".$userfile_type;
$newfile = substr($userfile, -9);
if($userfile_name = '') {
print("No file was selected!");
}
elseif($userfile_size > $MaxFileSize) {
print("The file to upload is too big");
}
elseif (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name']))
{
copy($HTTP_POST_FILES['userfile']['tmp_name'], $uploaddir."/files/".$intpic);
#copy($_FILES['userfile']['tmp_name'], $uploaddir."/files/".$intpic);
$global_db = mysql_connect('localhost', 'root');
mysql_select_db('some', $global_db) or die("Connection error");
$query = "INSERT INTO test (File, pic, imgname, imgtime) VALUES ('$newfile$type','".$_POST['pic']."', '".$_POST['intpic']."', '".$_POST['time']."')";
$result = mysql_query($query) or die("ERROR");