Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* CODE FOR HANDLING PICUP PHOTO UPLOADS */
- require 'config.php';
- // Include File Upload Class
- require BASEPATH .'_'. DS .'upload.class.php';
- if( !isset($_FILES['picup-photo']) ) {
- die( json_encode( array('error' => true, 'key' => key($_FILES)) ) );
- }
- $upload = new fileUpload();
- $upload->set_attrs( array(
- 'rename_file' => true,
- 'upload_dir' => BASEPATH . UPLOAD_DIR . DS
- ));
- // Set accepted file types
- $upload->setFileTypes( array('jpg', 'png', 'gif') );
- // Try processing uploaded file
- $result = $upload->upload($_FILES);
- if( !$result ) {
- // Check for error messages
- if( count($upload->message) < 1 )
- die( json_encode( array('error' => true, 'msg' => implode('<br>', $upload->message)) ) );
- // If no error messages, we'll just let them know it failed for some undetermined reason...
- die( json_encode( array('error' => true, 'msg' => 'Photo upload failed for unkown reason!') ) );
- }
- die( json_encode( array('error' => false, 'filename' => $upload->thefile) ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement