Hi All,
I want to save a file in a given location in server which takes data from my form and save that as a tab separated *.txt file, where I am able to generate the tsv file but to save I am not able to do. I want while I will hit submit then it should save that file to the location I want by taking all the data. If any kind of help then highly acceptable.
Thanks and Regards,
Chittaranjan :)
6 1414
If using the CGI module (which you should be) read the CGI documentation: perldoc CGI module
Kevin,
Thank you a lot for your quick response and I am able to save the file to the server but now the problem is that after saving the file I want to make the form stay at the last position but it is going to a new blank screen any help please....
Thanks,
Chittaranjan :)
I will need to see your code if you want help.
Yes I know if I can able to show you the code then that will help me but that is a very big file how to show at here I am not able to understand after all I am having some part of the functions I have hope that will work. -
if ( $q->param('confirm') ) {
-
-
if ( $self->{'download'} ) {
-
my $no = $q->param("noOfItems");
-
my $tloc = $q->param("noOfLocations");
-
# send the file to user
-
print $thisForm->processFormFinalDeliverData( $no, $tloc );
-
exit 1;
-
}
-
-
} elsif ( $q->param('confirmsend') ) {
-
if ( $self->{'download'} ) {
-
my $no = $q->param("noOfItems");
-
my $tloc = $q->param("noOfLocations");
-
my $upload_dir = "/autoweb/data/ess/MMCXTEST/forms";
-
-
# send the file to user
-
#my $data = $thisForm->processFormFinalDeliverData( $no, $tloc );
-
#&downloadFileSend( $self->{'formid'}, $data, $uid );
-
#my $act = "process";
-
#$thisForm->onSend( $self->{'formid'}, $no, $tloc, $act );
-
#print $thisForm->processFormFinalDeliverData( $no, $tloc );
-
my @success = ();
-
my $tsvdata = $thisForm->processFormFinalDeliverData( $no, $tloc );
-
my $filename = &downloadFileSend( $self->{'formid'}, $uid );
-
$filename =~ s/.*[\/\\](.*)/$1/;
-
-
open UPLOADFILE, ">$upload_dir/$filename" or die "Can't open $filename: $!";
-
print UPLOADFILE "$tsvdata";
-
close (UPLOADFILE) || die "Can't close $filename";
-
#$thisForm->onSend();
-
if (-s "$filename" >= 0) {
-
$thisForm->onSend();
-
}
-
#print $q->header('text/html'),
-
#$q->start_html(-title=>'Thanks!',bgcolor=>'#FFFFFF');
-
#if (@success) {
-
# print qq~<h3>@{[scalar @success]} files successfully uploaded:</h3>~;
-
#}
-
exit 1;
-
}
-
}
-
Here are two button calls where I am doing the file download in the first
if ( $q->param('confirm') )
That works fine which allow me to save the file to my local system with the dialog box for open or save. But in the second I want to save the file to the server. Where it saves that but after saving the file it takes the page to a new blank screen where I want to stay at the confirm screen.
Here are the code I think having some relation to that. -
sub downloadFileName {
-
warn 'downloadFileName';
-
my $fId = shift(@_);
-
my ( $sec, $min, $hour, $mday, $mon, $year ) = localtime time;
-
if ( $mon < 10 ) {
-
$mon = "0" . ( $mon + 1 );
-
} else {
-
$mon = $mon + 1;
-
}
-
if ( $mday < 10 ) {
-
$mday = "0" . $mday;
-
}
-
my $opfile = sprintf "%s_%s%s%s%s%s%s.txt",$fId,( $year + 1900 ),$mon,$mday,$hour,$min,$sec;
-
-
return $opfile;
-
}
-
-
=item downloadFileSend
-
-
Generate a file in /autoweb/data/ess/MMCXTEST/forms directory and
-
with the user id with the file name for the Sent file
-
-
=cut
-
-
sub downloadFileSend { warn 'downloadFileSend';
-
my $fId = shift(@_);
-
#my $data = shift(@_);
-
my $uid = shift(@_);
-
#my $upload_dir = "/autoweb/data/ess/MMCXTEST/forms";
-
my ( $sec, $min, $hour, $mday, $mon, $year ) = localtime time;
-
if ( $mon < 10 ) {
-
$mon = "0" . ( $mon + 1 );
-
} else {
-
$mon = $mon + 1;
-
}
-
if ( $mday < 10 ) {
-
$mday = "0" . $mday;
-
}
-
my $opfile = sprintf "%s_%s_%s%s%s%s%s%s.txt",$uid,$fId,( $year + 1900 ),$mon,$mday,$hour,$min,$sec;
-
-
#my $filename = $opfile;
-
#$filename =~ s/.*[\/\\](.*)/$1/;
-
#open UPLOADFILE, ">$upload_dir/$filename" or die "cannot open $filename: $!";;
-
#print UPLOADFILE "$data";
-
#close UPLOADFILE;
-
return $opfile;
-
}
-
-
sub extraheaders {
-
warn 'extraheaders';
-
my $self = shift;
-
my ($q) = @{$self}{'query'};
-
my %headers;
-
if (defined($q->param('confirm'))) {
-
$headers{'-attachment'} = &downloadFileName($self->{'formid'});
-
return %headers;
-
} #elsif (defined($q->param('confirmsend'))) {
-
# $headers{'-attachment'} = &downloadFileName($self->{'formid'});
-
# return %headers;
-
#}
-
else {
-
$self->SUPER::extraheaders(@_);
-
}
-
}
-
-
=item contenttype($q,$a)
-
-
contenttype is uses to set the MIME content-type HTTP header.
-
set based on the request parameters - when a file download is requested
-
-
=cut
-
-
sub contenttype { warn 'contenttype';
-
my $self = shift;
-
my $q = shift;
-
my $a = shift;
-
-
# initialize the state
-
$self->initializeProcess($q);
-
-
if ($self->{'download'}) {
-
return "text/plain";
-
}
-
-
$self->SUPER::contenttype(@_);
-
}
-
-
Hope this much will help me for shutting out the problem.
Thanks,
Chittaranjan
Sorry, I can't tell by looking at that code. If you want to display the confirmation page you either need to redirect to that page or manually print it out to the screen.
Sorry, I can't tell by looking at that code. If you want to display the confirmation page you either need to redirect to that page or manually print it out to the screen.
Thanks,
I will try to figure out a way to solve you as reference to your suggestion.
Chittaranjan:)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: sincethe2003 |
last post by:
The .aspx output html text to client browser,
how to save the out html to a html file on server disk automatically ?
|
by: Daniel |
last post by:
Hi all,
I just curious how to prompt a location msg box to allow save the file(grab
from server location such as c:\abc\d\") to the server side?
Any ideas?
Thank you.
Best regards,
GIn Lye...
|
by: John |
last post by:
Dear,
We have 2 IIS server on win2000. we use the web server for upload file from
server1 IIS to server2 IIS. We can connect from IIS1 to IIS2 success but the
file unable to upload with below...
|
by: Mark Denardo |
last post by:
My question is similar to one someone posted a few months back, but I don't
see any replies.
Basically I want to be able to have users upload photos and save them in a
database (as byte data)...
|
by: dave.kehring |
last post by:
So many threads about this with few answers. Here's how I solved my
problem.
I was trying to create an ASP.NET website on one of my servers from
Visual Studio.NET 2003 on my development machine....
|
by: andrewsteed |
last post by:
I have an Excel file on the server that I need to pass to the client. I tried dynamically generating the excel file through response.write's, but I was unable to get a file/table type that would...
|
by: neeraj |
last post by:
Hi all
I have developed desktop application in c#.net. I have installed it on
15 to 20 computers which all are in network. Application having some
setting in app.config file.
My problem it...
|
by: michael ngong |
last post by:
pramod@rtimes.com (Pramod Ramachandran) wrote in message news:<6616e304.0306240122.4dd3ecd5@posting.google.com>...
Permit me start with the second question.
It would be easier to be more...
|
by: JohnLorac |
last post by:
Hello,
can somebody help me with saving file into local disk
using javascript? I made some sample code which
unfortunately won't work :(.
Applet sample file:
public class IO extends...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |