Jump to content


Photo

File upload issues


  • Please log in to reply
No replies to this topic

#1 bcamp1973

bcamp1973
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 09 April 2006 - 07:46 PM

I have a modest CMS that i've created for a client and it intermittently refuses to accept the upload of files. usually PDFs. The CMS creats multisites for events. Each time an event is created the following code creates a folder for the event...


$eventidresult = @mysql_query("SELECT event_id FROM tbl_events WHERE event_title = '$_POST['event']'") OR build_query_error('GET EVENT ID QUERY');
$eventidrow = mysql_fetch_assoc($eventidresult);

if(!file_exists('documents/event/'.$eventidrow['event_id'])) {
   mkdir('documents/event/'.$eventidrow['event_id'], 0777);
   $message .= 'The <strong>Documents Directory</strong> has been created successfully!<br />';
} else {
   $error .= 'The documents directory could not be created for '.$_POST['event'];
}


then, the CMS can be used to upload files. This is the code i'm using for that...


if(move_uploaded_file($_FILES['upload']['tmp_name'], 'documents/event/'.$_SESSION['eventid'].'/'.$filename)) {
   $message .= '<strong>"'.$t.'"</strong> ('.$filename.') was successfully submitted!';
   $_POST[] = '';
} else {
   $error .= 'The file (<strong>'.$filename.'</strong>) could not be moved to the documents folder.<br />';
   $query = "DELETE FROM tbl_documents WHERE document_name = '$filename'";
   $result = @mysql_query($query);
}


i'm a newbie so this code is mostly stuff i've found other places and put together. I'm sure there's a LOT i could do to improve it. For right now i'd just like to be able to successfully upload files consistently!

Thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users