Jump to content

Archived

This topic is now archived and is closed to further replies.

bcamp1973

File upload issues

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!

Share this post


Link to post
Share on other sites

×

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.