Jump to content

Edit & Add image via Page Api


huseyin
 Share

Recommended Posts

Hello, 

i want to build a page for product add and edit. 

Products have also images. 

Is there any way i can include the image user interface like on the backend image field. Drag drop images and editing images. 

 

Is there any complete manual for such a page. 

Or any module for editing with page api (not frontend editing) 

Link to comment
Share on other sites

You can take a look at this module: 

Or you can build your own image uploader with something like Dropzone.js and some guide from this topic:

I think the main backend code to upload and save image to disk and add to page field is within this post: 

https://processwire.com/talk/topic/67-front-end-image-uploader-like-admin/?do=findComment&comment=3790

$size=filesize($_FILES['imageUpload']['tmp_name']);
	if ($size > MAX_SIZE*1024){
		print 'File troppo grosso';
		exit;
	}
	//copy the image in secure folder
	$image_name=time().'.'.$extension;
	$newname="../site/tmpfiles/profiles/".$image_name;
	$copied = copy($_FILES['imageUpload']['tmp_name'], $newname);
	if ($copied) {
		$userid	= $sanitizer->text($input->post->userid);
		$u = $users->get($userid);
		$u->setOutputFormatting(false);
		$u->profilephoto->add("http://".$_SERVER['HTTP_HOST']."/site/tmpfiles/profiles/".$image_name);
		$u->save();
                       //delete copied image
		$tmpfile = $_SERVER["DOCUMENT_ROOT"]."/site/tmpfiles/profiles/".$image_name;
		if (file_exists($tmpfile)) { unlink ($tmpfile); }

	}else{
		print "Errore nel salvataggio del file.";
		exit;
	}

 

  • Like 1
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...