Jump to content

500 internal server error in backend fields setup page


sirhc
 Share

Recommended Posts

Hi all,

I got a Internal Server Error when accessing de /setup/fields in my back end...
Also when i try to reach it through the page tree, i can't edit the 'fields' page, same error.

I do modify a image field through the api, i don't know if that has something to do with it, below the code i use to upload an image through the api, I deleted the parts that are not important. If anyone can help me that would be great.

To clarify; the code below works fine, my image and page is created as expected, the only thing is that I can't access my /setup/fields/ page in my CMS anymore due to the Internal Server Error.
 

  <?php     
        if($input->post->submit) {

            $photoPage = new Page(); // create new page object
            $photoPage->template = 'photo'; // set template
            $photoPage->parent     = wire('pages')->get('/foto/'); // set the parent
            
            $photoPage->name     = urlBuilder($input->title_photo); // give it a name used in the url for the page
            $photoPage->title     = $input->title_photo; // set page title (not neccessary but recommended)
            
            $photoPage->save();    
            
            // next: process photo upload
            
            // Set a temporary upload location where the submitted files are stored during form processing
            $upload_path = $config->paths->assets . "files/photos/";
            
            // New wire upload
            $file_upload = new WireUpload('file_upload'); // References the name of the field in the HTML form that uploads the photo
            $file_upload->setMaxFiles(1);
            $file_upload->setOverwrite(true);
            $file_upload->setDestinationPath($upload_path);
            $file_upload->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif'));
            
            // execute upload and check for errors
            $files = $file_upload->execute();
            
            // Run a count($files) test to make sure there are actually files; if so, proceed; if not, generate getErrors()
            if(!count($files)) {
                $file_upload->error("Sorry, but you need to add a photo!");
                return false;
            }
            //success
            
            //echo 'photos stored';exit;
            
       
            $photoPage->save();
            //$session->redirect($locationPage->url);
        } else {
    
?>

<section class="add-location">
    <div class="container">
        <div class="row">
            <div class="col-xs-12">
    
                <h2>Spot toevoegen</h2>
                <form id="add-form" action="" enctype="multipart/form-data" method="post">
                    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>" />
                    
                    <div class="col-xs-12 col-md-6">
                            <label for="fileselect">Upload jouw foto:</label>
                        <p>
                            
                            <input type="file" name="file_upload" id="file_upload" accept="image/*"  class="inputfile" />
                            <label for="file_upload">
                                <span></span> <strong><i class="fa fa-upload" aria-hidden="true"></i>
                                Kies je foto…</strong>
                            </label>
                            
                        </p>
                        </div>
                        
                        <input type="submit" name="submit" value="Upload" />
                    </div>
                </form>
    
            </div>
        </div>
    </div>
</div>

<?php } } include('./includes/foot.php');?>

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...