sam13579 Posted October 27, 2022 Share Posted October 27, 2022 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 More sharing options...
Jan Romero Posted October 28, 2022 Share Posted October 28, 2022 12 hours ago, sam13579 said: $uploadpage->programme_photo=$uploadPath.$file; I think you just need to change this to $uploadpage->programme_photo->add($uploadPath . $file); Have you checked if there are any errors from WireUpload? $doc->getErrors() Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now