Home  |  Linux  | Mysql  | PHP  | XML
From:J Alejandro Ceballos Z Date:Tue Jun 16 22:29:47 2009
Subject:Storing a file from a cgi parameter
I am trying to store a file in the temp directory.

It creates the desired file, but with size 0.

The files are videos sent via CGI. I tried with the upload function,  
but it did not work too.

Would you please give me some direction about what I am doing wrong or  
what should I do in order to make it work?

Thank you.



# Load system modules (strict disabled in order to prevent conflict)
use CGI;
# use strict;

# Create CGI
my $cgi_this = new CGI;
my $file_file = $cgi_this->param('sbvideo_file') || 0;

# retrieve original name and change it
if ($file_file =~ /(.+)\.(\w+)$/)
    { ($str_filename,$str_fileext) = ($1,$2); }
$str_filename = $$ . '.'. $str_fileext;

# this line does not work, sends error on hash content type key
#  $str_filetype = $cgi_this->uploadInfo($file_file)->{'Content-Type'};

# store file (that does not work)
       if (open (hFILE, ">~/tmp/$str_filename"))
         {
         binmode hFILE;
         while (<$file_file>)
           { print hFILE $_; }
         close (hFILE);
         }

# store file 2nd option (and this one neither)
       if (open (hFILE, ">~/tmp/$str_filename"))
         {
         binmode hFILE;
         while (read($file_file,$str_buffer,1024))
           { print hFILE $str_buffer; }
         close (hFILE);
         }




Atentamente,

J. Alejandro Ceballos Z.

    w: http://alejandro.ceballos.info
    e: buzon@alejandro.ceballos.info
    m: +52 (33) 1411.6079



Navigate in group perl.beginners.cgi at sever nntp.perl.org
Previous Next


Your recent visits
Re: [PHP-WIN] problem with PEAR , windows platform , php 5.2.9-2 , IIS Version 6
cvs: phpdoc-fa /language constants.xml


  
© No Copyright
You are free to use Anything
Site Maintained by Zareef Ahmed
Powered By PHP Consultants