Jump to content


jamienk

Member Since 19 Apr 2012
Offline Last Active Feb 21 2013 10:23 PM
-----

Topics I've Started

New page

18 February 2013 - 04:30 PM

Hi,

 

From the PW admin, when I create a "new" child page, I'm first prompted to create a 'title' and 'name' before being sent to the fuller template. Can I by-pass this screen? Our "title" and "name" fields are auto-generated based on other field values, so it's a bit confusing to have to type something here...

 

Thanks

 

-Jamie


images->path files->path

19 April 2012 - 05:38 AM

I've upgraded to PW 2.2 and some of my code has stopped working. I allow my authenticated users to upload pdfs, but I can no longer upload or get the path or url of the uploads.

This used to work (edited code to only show the relevent part):

$newpage = new Page();
$path=$newpage->images->path;
$relpath=$newpage->images->url;

Then I save the page with the correct fields filled in. Then I upload the file:

$name = strtolower($sanitizer->name($_FILES['upload']['name']));
$file = $path . $name;
if(move_uploaded_file($_FILES['upload']['tmp_name'], $file)) {
		// add it to the page
		$newpage->report_request->add($file);
		/// save the page
		$newpage->save();	  
	}

But now $path and $relpath don't return anything. I get the error "Notice: Trying to get property of non-object" which I think refers to images->path and images->url

I've tried files->path and files->url (in some of the sample code from these forums I picked up that possibility), but that doesn't work either.

How do I access the filesystem path and the url path, both to upload the file and to refer to it?

Thank you,
Jamie