Home  |  Linux  | Mysql  | PHP  | XML
From:J Alejandro Ceballos Z Date:Wed Jun 17 02: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: Auto detect timezone
Re: Web photo album, is this possible in CGI
Re: Showing errors with user input
Re: Global scope
Web photo album, is this possible in CGI



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants