2

So in BulletProof's documentation, I follow what I had to do and the image doesn't even get to "echo" phase #2.

https://github.com/samayo/bulletproof/blob/master/README.md

if (isset($_POST['post_blog_submit'])) {

    $image = new Bulletproof\Image($_FILES);
    $title = $filter->input("string", $_POST['title']);
    $body = $filter->input("string", $_POST['body']);

    $image->setName('test')
        ->setMime(array('jpg'))
        ->setLocation('/data/gallery', 777)
        ->setDimension(250, 250)
        ->setSize(100, 10000000);

    if($image['bthumb']){
        echo 'Phase #2'; 

        if($image->upload()){
            echo $image->getName(); // samayo
            echo $image->getMime(); // gif
            echo $image->getLocation(); // avatars
            echo $image->getFullPath(); // avatars/samayo.gif
            echo 'uploaded';
        } else {
            echo $image['error']; 
        }
    }

    echo $image['error'];
}

This is my PHP code, which does exactly what README.MD stated for me to do.

 <form name="post_blog" method="post" enctype="multipart/form-data">

                                            <label for="title">Blog Title</label>
                                            <input class="form-control" type="text" name="title" placeholder="Blog Title" required /> <br/>

                                            <label for="body">Blog Body</label>
                                            <textarea class="form-control" name="body" placeholder="Place your text ..."  required> </textarea> <br/>

                                            <label for="bthumb">Blog Thumbnail</label>
                                            <input type="hidden" name="MAX_FILE_SIZE" value="10000000"/>
                                            <input type="file" name="bthumb" /> <br/>

                                            <div class="pull-right">
                                                <input type="hidden" name="post_blog_submit" value="1" />
                                                <input type="submit" class="btn btn-danger" value="Submit!" />
                                            </div>
                                        </form>

I don't know what is possibly wrong, the form part of it looks correct and the backend looks correct. But it isn't even detecting the input itself.

samayo
  • 16,163
  • 12
  • 91
  • 106
Cameron Swyft
  • 448
  • 2
  • 6
  • 21
  • how is this related to smarty or bootstrap? – Borgtex Oct 22 '15 at 09:25
  • 1) make sure you have `require_once "path/to/bulletproof.php";` 2) I don't know what is $filter, are you sure it is initialized properly 3) you may have error like this `PHP Warning: move_uploaded_file(): Unable to move '/tmp/php55FeAr' to 'bulletproof/156649052b79af_pjlkgqomnhefi.jpeg'` due to permission problem – pavlovich Dec 06 '15 at 19:54
  • answer already provided in the chat room – samayo Feb 25 '16 at 08:39

0 Answers0