Jump to content

File upload issues


bcamp1973

Recommended Posts

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...

[code]

$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'];
}

[/code]

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

[code]

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);
}

[/code]

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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.