in reply to Proble with image on Perl-CGI

<img src="/var/www/upload/$filename" alt="Photo" />

If you domain is example.com, the browser will try to load the image http://example.com/var/www/upload/$filename, which is not what you want. You need to supply the path relative to your document root, for example /upload/$filename.

Replies are listed 'Best First'.
Re^2: Proble with image on Perl-CGI
by daynite (Initiate) on Mar 26, 2009 at 15:31 UTC

    Hi.. thanks for your reply..

    i have shifted the 'upload' directory from /var/www/upload to var/www/cgi-bin/session/cgi/upload ......

    and in script i have made the below changes,

    my $upload_dir = "/var/www/cgi-bin/session/cgi/upload";

    and

    img src="/upload/$filename" alt="Photo" />

    still it is not working...

      if the URL starts with a /, it is interpreted relative to your domain name, not to the script (sorry if I was unclear about that).

      Please don't move upload directories into a cgi-bin dir, that might be a huge security risk. Let it stay in /var/www/upload, and link to it with href="/upload/$filename".

        i moved the 'upload' folder in to /var/www/

        and in i modified the script like below

        my $upload_dir = "/var/www/upload";

        and

        Photo

        sorry ... if i not understood..

        i have moved 'upload' folder to /var/www/

        and i modified my script with..

        my $upload_dir = "/var/www/upload";

        and

        Photo