Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
The web server's root and your OS's root are different. The web server won't look outside it's tree. If you write your image file to a location outside the server's DocumentRoot, your web server can't find it.

You can

  1. use the Alias directive to have a location point to some path outside the DocumentRoot
  2. allow the webserver process to write to some images directory inside the tree rooted at DocumentRoot
  3. use a CGI script to serve the image. Provide e.g. the tag
    <img src="/cgi-bin/image.pl?img=$tag.jpg">
    in the page referencing the image, and have it served thusly:
    #!/usr/bin/perl -T use CGI; use strict; my $q = new CGI; if($q->param('img') =~ /^([\w\.\-]+)$/) { # untaint my $file = $1; if(-f "/tmp/$file") { if(open(I,'<',"/tmp/$file")) { print $q->header(-content_type => "image/jpeg"); print while <I>; close I; exit; } } } print $q->header(-status => '404 Not found'); print "<h1>Not found.</h1>\n";
As for 1. and 2. - if you allow your web server to write to some path, you should limit the methods POST, PUT and DELETE for that directory (or location).

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

In reply to Re: CGI-Perl:: Location for saving the GD output by shmem
in thread CGI-Perl:: Location for saving the GD output by cool

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (7)
    As of 2020-05-26 10:44 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      If programming languages were movie genres, Perl would be:















      Results (150 votes). Check out past polls.

      Notices?