Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-06-22 15:47:42

baby
Plugin Author
From: Buenos Aires, Argentina
Registered: 2005-10-16
Posts: 95
Website

uploading images (or files, for that matter) from the public side

Hi,

I’m trying to upload an image from a plugin that will run in the public side… I think I’m doing things rather ‘by the book’, however, I can’t find my file anywhere :-(

What I want to do is something along the lines of what was asked for here

I’m preparing a couple of tags to add to the comments and comment_form forms. The latter would have an <input type="file" /> tag to upload the image and the former would be a tag to show the image.

I didn’t advance on the internals (‘though I have an idea of what to do), simply because I can’t upload the file…

Is Textpattern somehow preventing the $_FILES array from being filled if I’m on the public side?

Is there a way to circumvent this?

The tag in the comment_form form would have something like this:

$ort_image_name = $_FILES['ort_image']['name'];

$out .= "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$max_file_size\" />\n";
$out .= "<input type=\"file\" name=\"ort_image\" value=\"$ort_image_name\" size=\"$isize\" class=\"$class\" id=\"ort_image\" />\n";
return $out;

however, whether I press preview or submit $_FILES is always empty…

Any hints?


Mariano AbsatzEl Baby

I don’t suffer from insanity. I enjoy every minute of it.

Offline

#2 2008-06-22 16:40:45

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: uploading images (or files, for that matter) from the public side

Does your HTML form tag have the enctype="multipart/form-data" attribute set?
Otherwise I don’t think $_FILES will contain anything. TXP itself doesn’t prevent this.

Offline

#3 2008-06-22 16:49:04

baby
Plugin Author
From: Buenos Aires, Argentina
Registered: 2005-10-16
Posts: 95
Website

Re: uploading images (or files, for that matter) from the public side

YES!

You’re right… that was it… silly of me… now I have to think if there’s an elegant way to add that to the standard comment form (I seriously doubt it) or what else I can do.

Thanx a lot, ruud.


Mariano AbsatzEl Baby

I don’t suffer from insanity. I enjoy every minute of it.

Offline

Board footer

Powered by FluxBB