upload_success to reflect image w/ email submit |
[eluser]oldnews[/eluser]
My project couples an online photo upload with a user submission email form. First, the user uploads a JPEG image restricted to our file size and dimension limts. Then, upon success, the image appears on the upload_success view along with an email form to submit the image concurrent with user info. My image upload method works great, but I've had no joy in passing a variable for $data['file_name'] from the controller to the upload_success view. There's really no need to pass the entire $data array, but, ideally I would also prefer to pass 'image_width' and "image-height' variables to the view and halving their pixel dimensions on the fly (without the need for an adjunct folder to store those transitory downsized copies). Another issue, which I plan to tackle once I get THIS to work, is extending a class Form in the controller for the upload_success view which is already powered by class Upload. Then, users could submit, in step 2, text fields about themselves and their photo (with validation) and the image auto-attached. I am using the recommended templates and methods supplied in the CI user_guide. Here are coding excerpts with 3 failed methods to pass the file_name variable commented out from the end of the upload.php controller and the entire upload_success view which yields an error for undefined variable image. Any guidance that can help me get on the right track would be immensely appreciated. Code: else Code: <head>
[eluser]LuckyFella73[/eluser]
did you try something like this: Code: $data['upload_data'] = $this->upload->data();
[eluser]oldnews[/eluser]
Thanks. Actually, to avoid possible duplicate filenames in my upload folder, libraries/Upload.php modifies user's filename by appending a 1, 2, 3, et cetera, so I must pass the associated (possibly modified) $data['file_name'] to assure the correct photo is reflected, and attached in the subsequent email submission
[eluser]oldnews[/eluser]
I tried LuckyFella73's code substitution in the Upload controller and it performed exactly as does: Code: $data = array('upload_data' => $this->upload->data()); Code: <html> uploadpixmaverik.com
[eluser]oldnews[/eluser]
I'm coming to the conclusion that what I want to accomplish cannot be accomplished given the tools I have to work with. I have read the user-guide and thought, perhaps loading the parser library might yield the clean echo of a single chosen value from the upload data array using {} braces surrounding the desired value. But the parser->parse, when uncommented in the controller, only duplicated what load->view does, i.e., run the entire data dump, and the braces are returned as plain html text. The other possible solution attempted in the view to echo the desired value as a stand-alone yielded a "Trying to get property of non-object" error. Yes, I am trying to get the property value of a data array constructed by a CI boilerplate library for uploaded images. If this is nothing more than an exercise in futility, then I suppose it explains why there's no workable solution to reflect the user's uploaded picture in an upload_success view. upload controller (end game): Code: else upload_success view: Code: <html> UploadPixMaverik
[eluser]LuckyFella73[/eluser]
Maybe I didn'd understand what you were trying to do - sorry for that. If I get you right (this time) you want the just uploaded image shown on the succes page. If thats the case you could do it this way: Controller: Code: <?php Success page: Code: <head>
[eluser]oldnews[/eluser]
LuckyFella73, Thank you. Code works great; elegant solution! |
Welcome Guest, Not a member yet? Register Sign In |