<body> <!--put in some formatting --> <nav class=""> <div> <ul class="nav navbar-nav"> <li class="active"><a href="View.php">View Files</a></li> </ul> </div> </nav> <form enctype="multipart/form-data" action="#" method="POST"> Send this file: <input name="upfile" type="file" /> <input type="submit" value="Save File" /> </form> <?php // Util Class New Instance $util = new Util(); // Check to see if there is a POST request on the page from the Util Class if ($util->isPostRequest()) { try { $upfile = 'upfile'; $file_upload = new File_upload(); $file_upload->addFile($upfile); } catch (RuntimeException $e) { echo $e->getMessage(); } } ?> </body> </html>
public function update() { // Create object for this ticket. $this_ticket = $this->tickets->whereMaster_id(Input::get('ticket_id'))->first(); // Validate form fields first if (!$this->tickets->isValid($input = Input::all())) { return Redirect::back()->withInput()->withErrors($this->tickets->errors); } // Process post data. // Also check if user is support/admin - this will tell the add_ticket function to process POST values for submitted/assigned/status fields. $post_result = $this->tickets->update_ticket(Input::all(), $this->support_check); // Process file if it was uploaded. $file_result = true; // Set default to true in case there's no file attach. False will be returned if there's probs. if (!empty($_FILES['related_files']['name'][0])) { $file_upload = new File_upload(); $file_result = $file_upload->upload_related_files(Input::file('related_files'), $this_ticket->master_id); } if ($post_result && $file_result) { return Redirect::back()->with('ticket_update_success', 'Ticket updated successfully!'); } else { if ($post_result['result'] && !$file_result) { return Redirect::route('tickets.index')->with('ticket_add_file_failed', 'Ticket added successfully, but something went wrong with the file upload. Please contact support.'); } } return Redirect::back()->with('ticket_update_failed', 'Sorry, there was a problem updating your ticket. Please contact support.'); }