Re: teaching myself perl - stumped on this one!

From: Abhinav (Me_at_myco.com)
Date: 03/08/04


Date: Mon, 08 Mar 2004 10:40:40 +0530

Hi Martin,

Martin Livingston wrote:
> Hi,
>
> I bought a book ( PERL and CGI For the World Wide Web - Elizabeth Castro )
> learn the basics. I have put together a dozen or so working scripts but this
> one has me stumped.
>
> This is a "real world" exercise. I am putting together a "cookbook" for a
> friend. She fills in a form with the recipe details and selects a image file
> to appear on the finished web page. When she "submits" the form it returns a
> copy of the preview page with the image in place where the image file is
> stored in a temporary location on my server. Up to this point everything
> works just fine.
>
> If she is happy with the preview page, she "submits" this page to be stored
> on the server. The html gets written correctly to the server but the image
> file only creates the file name without any data in the permanent images
> directory. However, the script deletes the old file properly.
>
> Here is the first portion of the script (with the absolute paths blanked
> out). I am sure I am just using the FILEHANDLES incorrectly and would
> appreciate any help available out there. I used comment lines to explain
> what I am trying to do.
>
> Thanks
> Martin L.
>
> #!/usr/bin/perl
> use CGI ':standard';
>
> #import the data from the hidden fields from the recipe preview page
>
> $catagory=param("catagory");
> $name=param("name");
> $description=param("description");
> $source=param("source");
> $origin=param("origin");
> $ingredients=param("ingredients");
> $method=param("method");
> $service=param("service");
> $picture=param("picture");
> $filename= param("filename");
> $imgfilename = param("imgfilename");
>
> #build the meta tags for the website search engine
>
> $meta = $catagory . " " . $name . " " . $description . " " . $source . " " .
> $origin;
>
> #see if picture file was uploaded
>
> if ($picture) {
>
> #get image from temporary image directory
>
> open (TEMPORARY, "</xxx/xxx/x/xx/xx/xxxxx/web/nugget/temp/$imgfilename");
>
> $temp_img=(TEMPORARY);
>
> close (TEMPORARY);
>
> #delete temporary image file
>
> unlink ("/xxx/xxx/x/xx/xx/xxxxx/web/nugget/temp/$imgfilename");
>
> #copy image file to the cookbook images directory
>
> open (IMAGEFILE,
> ">>/xxx/xxx/x/xx/xx/xxxxx/web/nugget/cookbook/images/$imgfilename");
>

This cold be a red herring (and Im nerw to perl too ! ) but shouldn't
the above FILEHANDLE be opened with ">" instead of ">>" ?
> print IMAGEFILE "$temp_img";
>
> close (IMAGEFILE);
>
> }
>
> #Copy html to the appropriate folder in the cookbook directory
>
> open (PAGEFILE,
> ">/xxx/xxx/x/xx/xx/xxxxx/web/nugget/cookbook/$catagory/$filename");
> print PAGEFILE qq(<html>\n<head>\n<title>$name</title>\n</head>\n<body>\n);
> print PAGEFILE qq(<META NAME=description CONTENT=$description>\n);
> print PAGEFILE qq(<META NAME=keywords CONTENT= $meta>\n);
> print PAGEFILE qq(<body bgcolor="#e6e6fa" TOPMARGIN=5 LEFTMARGIN=2
> MARGINHEIGHT=0 MARGINWIDTH=2>\n);
> print PAGEFILE qq(<table width=600 align=center CELLPADDING=0 border=0
> CELLSPACING=0>\n);
>
>
Please let me know if thats the problem or I've pointed out a no-go .. :)

Regards
Abhinav



Relevant Pages

  • teaching myself perl - stumped on this one!
    ... She fills in a form with the recipe details and selects a image file ... the script deletes the old file properly. ... #get image from temporary image directory ... print PAGEFILE qq; ...
    (comp.lang.perl.misc)
  • Re: wrote directory full of pictures in a file urgggg!
    ... picture files written into a single file. ... If your script did something like ... An image file with other stuff concatentated onto the end of it is ... Even if you're not currently using Solaris, ...
    (comp.unix.questions)
  • Re: Backing up system
    ... space since the null filled sectors compress to almost nothing. ... That script does it, ... cleandrive5 and cleandrive6 ... Produced a 12GB compressed image file. ...
    (Fedora)
  • Re: Looking for script setting a pixel marker in an image
    ... I will master up all my humble Perl knowledge and give that a try! ... image file at position x|y (whereas xmax and ymax are the maximum ... width and height of that image in pixels). ... filename.ext and the path can be define hardcoded in the script. ...
    (comp.lang.perl.misc)