Re: [symfony-users] Linking to the upload path from a template.
Thank you both. I hope that'll solve my problem. Luis. On Fri, Mar 12, 2010 at 1:48 PM, Gábor Fási wrote: > public_path(), > http://www.symfony-project.org/api/1_4/UrlHelper#method_public_path > > On Fri, Mar 12, 2010 at 16:58, Luis Alberto Zarrabeitia > wrote: >> Moreover, it produces the image tag, but I can't find the way to >> access the url (for instance, if I want to link to it). Any thoughts? > > -- > If you want to report a vulnerability issue on symfony, please send it to > security at symfony-project.com > > You received this message because you are subscribed to the Google > Groups "symfony users" group. > To post to this group, send email to symfony-users@googlegroups.com > To unsubscribe from this group, send email to > symfony-users+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/symfony-users?hl=en > -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
Re: [symfony-users] Linking to the upload path from a template.
public_path(), http://www.symfony-project.org/api/1_4/UrlHelper#method_public_path On Fri, Mar 12, 2010 at 16:58, Luis Alberto Zarrabeitia wrote: > Moreover, it produces the image tag, but I can't find the way to > access the url (for instance, if I want to link to it). Any thoughts? -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
Re: [symfony-users] Linking to the upload path from a template.
Why not give the following a try? On Fri, Mar 12, 2010 at 5:58 PM, Luis Alberto Zarrabeitia wrote: > On Fri, Mar 12, 2010 at 2:00 AM, Gareth McCumskey > wrote: >> In your template: >> >> > image_tag($sf_config->get('sf_upload_dir').'/myImages/'.$image_name) >> ?> >> >> The $sf_config variable is a copy of the sfConfig object used in the actions. > > Thank you, but I'm afraid that didn't work. Instead, it printed the > error message: > > Notice: Undefined variable: sf_config in ..path/to/the/template.php.. > on line 24 Fatal error: Call to a member function get() on a > non-object in on line 24. It seems that $sf_config is not > available in my template. Does that make any sense? (symfony 1.4 > here). > > Instead, I tried using sfConfig::get('sf_upload_dir'). The result was > slightly better: > > src="/myapp/projects/myapp/web/uploads/myImages/5e1a2b0308e404ecd8128b933f667274039e9e59.jpg" > /> > > The first "/myapp/" is the right webpath to the /web/ directory, but > sf_upload_dir seems to hold the filesystem path to the upload > directory (/projects/myapp/web/uploads/), rather than the webpath. > > Remiving it form the path yielded better results: > > did display > the image tag, though it has the /uploads/ part hardcoded. > > Moreover, it produces the image tag, but I can't find the way to > access the url (for instance, if I want to link to it). Any thoughts? > > (and where can I find the list of functions and variables I can use > from the template?) > > Thanks, > > Luis. > > -- > If you want to report a vulnerability issue on symfony, please send it to > security at symfony-project.com > > You received this message because you are subscribed to the Google > Groups "symfony users" group. > To post to this group, send email to symfony-users@googlegroups.com > To unsubscribe from this group, send email to > symfony-users+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/symfony-users?hl=en > -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
Re: [symfony-users] Linking to the upload path from a template.
On Fri, Mar 12, 2010 at 2:00 AM, Gareth McCumskey wrote: > In your template: > > image_tag($sf_config->get('sf_upload_dir').'/myImages/'.$image_name) > ?> > > The $sf_config variable is a copy of the sfConfig object used in the actions. Thank you, but I'm afraid that didn't work. Instead, it printed the error message: Notice: Undefined variable: sf_config in ..path/to/the/template.php.. on line 24 Fatal error: Call to a member function get() on a non-object in on line 24. It seems that $sf_config is not available in my template. Does that make any sense? (symfony 1.4 here). Instead, I tried using sfConfig::get('sf_upload_dir'). The result was slightly better: The first "/myapp/" is the right webpath to the /web/ directory, but sf_upload_dir seems to hold the filesystem path to the upload directory (/projects/myapp/web/uploads/), rather than the webpath. Remiving it form the path yielded better results: did display the image tag, though it has the /uploads/ part hardcoded. Moreover, it produces the image tag, but I can't find the way to access the url (for instance, if I want to link to it). Any thoughts? (and where can I find the list of functions and variables I can use from the template?) Thanks, Luis. -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
Re: [symfony-users] Linking to the upload path from a template.
In your template: get('sf_upload_dir').'/myImages/'.$image_name) ?> The $sf_config variable is a copy of the sfConfig object used in the actions. On Fri, Mar 12, 2010 at 12:10 AM, Luis Zarrabeitia wrote: > > Hello. I'm new to Symfony and I decided to learn by developing a small > web app. > > Right now, I have a form that uploads an image: > > 'image' => new sfValidatorFile(array( > 'required' > => false, > > 'path' => sfConfig::get('sf_upload_dir').'/myImages', > > 'mime_types' => 'web_images', > )), > > > The images are getting uploaded to the right place (http://localhost/ > myapp/uploads/myImages). Now, when I try to include them from a > template, how do I access the web path? I don't want to hardcode / > myapp/uploads, because at least the /myapp part could change (for > instance, on deployment). Is there any configuration setting or > variable that I could access from the template? > > Also, it seems that the sfValidatorFile stores/returns only the > filename, which means that I will have to hardcode /myImages. Am I > missing something? Is there a better way to retrieve the path relative > to the upload dir? > > Luis. > > -- > If you want to report a vulnerability issue on symfony, please send it to > security at symfony-project.com > > You received this message because you are subscribed to the Google > Groups "symfony users" group. > To post to this group, send email to symfony-users@googlegroups.com > To unsubscribe from this group, send email to > symfony-users+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/symfony-users?hl=en > -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
[symfony-users] Linking to the upload path from a template.
Hello. I'm new to Symfony and I decided to learn by developing a small web app. Right now, I have a form that uploads an image: 'image' => new sfValidatorFile(array( 'required' => false, 'path' => sfConfig::get('sf_upload_dir').'/myImages', 'mime_types' => 'web_images', )), The images are getting uploaded to the right place (http://localhost/ myapp/uploads/myImages). Now, when I try to include them from a template, how do I access the web path? I don't want to hardcode / myapp/uploads, because at least the /myapp part could change (for instance, on deployment). Is there any configuration setting or variable that I could access from the template? Also, it seems that the sfValidatorFile stores/returns only the filename, which means that I will have to hardcode /myImages. Am I missing something? Is there a better way to retrieve the path relative to the upload dir? Luis. -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en