Lassie Posted April 17, 2009 Share Posted April 17, 2009 I am trying to adapt wordpress 2.7 to my purposes,pricipally a cms rather than blog. I have created several pages with individual templates that work fine, however the last page i have created concerning an upload program, ignores a call to the wp footer function. I had a similar problem when creating another template which ignored all wp function calls and gave an error undefined function get_header(). I am wondering debug this. Any help appreciated although I realise its not a strict php question, the wp forum is not responding. the code for the page in question <?php /* Template Name: registration */ ?> <?php get_header();?> <div id="leftnav"> <?php include (TEMPLATEPATH . '/sidebar1.php'); ?> <div id="right_pan". </div> </div> <div id="rightnav"> </div> <div id="content"> <p>Simple Upload following registration</p> <?php get_currentuserinfo(); global $current_user; if (isset($current_user)){ echo $current_user->user_login; } // define a constant for the maximum upload size define ('MAX_FILE_SIZE', 51200); if (array_key_exists('upload', $_POST)) { // define constant for upload folder define('UPLOAD_DIR', 'C:/upload_test/'); // replace any spaces in original filename with underscores // at the same time, assign to a simpler variable $file = str_replace(' ', '_', $_FILES['image']['name']); // convert the maximum size to KB $max = number_format(MAX_FILE_SIZE/1024, 1).'KB'; // create an array of permitted MIME types $permitted = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png'); // begin by assuming the file is unacceptable $sizeOK = false; $typeOK = false; // check that file is within the permitted size if ($_FILES['image']['size'] > 0 && $_FILES['image']['size'] <= MAX_FILE_SIZE) { $sizeOK = true; } // check that file is of an permitted MIME type foreach ($permitted as $type) { if ($type == $_FILES['image']['type']) { $typeOK = true; break; } } if ($sizeOK && $typeOK) { switch($_FILES['image']['error']) { case 0: //take user name or id from session variable //$username = $_SESSION['first_name']; // if the user's subfolder doesn't exist yet, create it if (!is_dir(UPLOAD_DIR.$current_user->user_login)) { mkdir(UPLOAD_DIR.$current_user->user_login); } // check if a file of the same name has been uploaded // check if a file of the same name has been uploaded. if it has timestamp duplicate if (!file_exists(UPLOAD_DIR.$current_user->user_login.'/'.$file)) { // move the file to the upload folder and rename it $success = move_uploaded_file($_FILES['image']['tmp_name'], UPLOAD_DIR.$current_user->user_login.'/'.$file); } //timestamp duplicate else{ $success = move_uploaded_file($_FILES['image']['tmp_name'], UPLOAD_DIR.$current_user->user_login.'/'.time().$file); } if ($success) { $result = "$file uploaded successfully"; } else { $result = "There was an error uploading $file. Please try again."; } break; case 3: $result = "There was an error uploading $file. Please try again."; default: $result = "System error uploading $file. Contact webmaster."; } } elseif ($_FILES['image']['error'] == 4) { $result = 'No file selected'; } else { $result = "$file cannot be uploaded. Maximum size: $max. Acceptable file types: gif, jpg, png."; } } // if the form has been submitted, display result if (isset($result)) { echo "<p>$result</p>"; } ?> <h1>Upload Your Timeshare Photos</h1> <div style="text-align: center"> <table width = \"390\" border = 0 align="left"> <tr><td> <form action="" method="post" enctype="multipart/form-data" name="uploadImage" id="uploadImage"> <fieldset> <legend>Upload images for your timeshare</legend> <p> <label for="image">Upload image:<em class="required">(only jpg,gif,png.Max size 50Kb)</em></label> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo MAX_FILE_SIZE; ?>" /> <input type="file" name="image" id="image" /> </p> <p> <input type="submit" name="upload" id="upload" value="Upload" /> </p></fieldset> </form> </td></tr></table> <?php get_footer();?> Link to comment https://forums.phpfreaks.com/topic/154523-solved-problem-with-custom-php-in-wordpress-page/ Share on other sites More sharing options...
Lassie Posted April 17, 2009 Author Share Posted April 17, 2009 reloading wp fixed issue Link to comment https://forums.phpfreaks.com/topic/154523-solved-problem-with-custom-php-in-wordpress-page/#findComment-812501 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.