Jump to content

How to upload a file/image from front-end form?


sam13579
 Share

Recommended Posts

I want to create a form field with which I can upload the image/file. But it is not working. Is there anyone to guide?
 

$saved="";    
echo $_FILES['pp']['name'];
    if ($_SERVER['REQUEST_METHOD'] == "POST") {
$upload_path = $config->paths->assets . "files/.tmp_uploads/";
        print_r($tempdir);


    $doc = new WireUpload('pp');
    $doc->setMaxFiles(1);
    $doc->setOverwrite(true);
    $doc->setDestinationPath($upload_path);
    $doc->setValidExtensions(array('jpg', 'jpeg', 'png', 'pdf'));
    $files = $doc->execute();
print_r($files);
 $uploadpage = new Page();
        $uploadpage->template = "progr";
        $uploadpage->parent = $pages->get("/add-progr/");
        // add title/name and make it unique with time and uniqid
        $uploadpage->title = "Some Text";

        $uploadpage->save();
        foreach($files as $file){
                $uploadpage->programme_photo=$uploadPath.$file;
            print_r($file);
        };
        $uploadpage->save();
        $saved="Saved";

 

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...