473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Saving a file to a Particular Server Location

Chittaranjan
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 :)
Apr 9 '07 #1
6 1414
KevinADC
4,059 Expert 2GB
If using the CGI module (which you should be) read the CGI documentation:

perldoc CGI module
Apr 9 '07 #2
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 :)
Apr 9 '07 #3
KevinADC
4,059 Expert 2GB
I will need to see your code if you want help.
Apr 9 '07 #4
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.

Expand|Select|Wrap|Line Numbers
  1. if ( $q->param('confirm') ) {
  2.  
  3.     if ( $self->{'download'} ) {
  4.         my $no = $q->param("noOfItems");
  5.         my $tloc = $q->param("noOfLocations");
  6.         # send the file to user
  7.         print $thisForm->processFormFinalDeliverData( $no, $tloc );
  8.         exit 1;
  9.     }
  10.  
  11. } elsif ( $q->param('confirmsend') ) {
  12.     if ( $self->{'download'} ) {
  13.         my $no = $q->param("noOfItems");
  14.         my $tloc = $q->param("noOfLocations");
  15.         my $upload_dir = "/autoweb/data/ess/MMCXTEST/forms";
  16.  
  17.         # send the file to user
  18.         #my $data = $thisForm->processFormFinalDeliverData( $no, $tloc );
  19.         #&downloadFileSend( $self->{'formid'}, $data, $uid );
  20.         #my $act = "process";
  21.         #$thisForm->onSend( $self->{'formid'}, $no, $tloc, $act );
  22.         #print $thisForm->processFormFinalDeliverData( $no, $tloc );            
  23.         my @success = ();
  24.         my $tsvdata = $thisForm->processFormFinalDeliverData( $no, $tloc );
  25.         my $filename = &downloadFileSend( $self->{'formid'}, $uid );
  26.         $filename =~ s/.*[\/\\](.*)/$1/;
  27.  
  28.         open UPLOADFILE, ">$upload_dir/$filename" or die "Can't open $filename: $!";
  29.         print UPLOADFILE "$tsvdata";
  30.         close (UPLOADFILE) || die "Can't close $filename";
  31.         #$thisForm->onSend();
  32.         if (-s "$filename" >= 0) {
  33.             $thisForm->onSend();
  34.         }
  35.         #print $q->header('text/html'),
  36.         #$q->start_html(-title=>'Thanks!',bgcolor=>'#FFFFFF');
  37.         #if (@success) {
  38.         #    print qq~<h3>@{[scalar @success]} files successfully uploaded:</h3>~;
  39.         #}
  40.         exit 1;
  41.     }
  42. }
  43.  
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.

Expand|Select|Wrap|Line Numbers
  1. sub downloadFileName {
  2.     warn 'downloadFileName';
  3.     my $fId = shift(@_);
  4.     my ( $sec, $min, $hour, $mday, $mon, $year ) = localtime time;
  5.     if ( $mon < 10 ) {
  6.         $mon = "0" . ( $mon + 1 );
  7.     } else {
  8.         $mon = $mon + 1;
  9.     }
  10.     if ( $mday < 10 ) {
  11.         $mday = "0" . $mday;
  12.     }
  13.     my $opfile = sprintf "%s_%s%s%s%s%s%s.txt",$fId,( $year + 1900 ),$mon,$mday,$hour,$min,$sec;
  14.  
  15.     return $opfile;
  16. }
  17.  
  18. =item downloadFileSend
  19.  
  20. Generate a file in /autoweb/data/ess/MMCXTEST/forms directory and
  21. with the user id with the file name for the Sent file
  22.  
  23. =cut
  24.  
  25. sub downloadFileSend { warn 'downloadFileSend';
  26.     my $fId = shift(@_);
  27.     #my $data = shift(@_);
  28.     my $uid = shift(@_);
  29.     #my $upload_dir = "/autoweb/data/ess/MMCXTEST/forms";
  30.     my ( $sec, $min, $hour, $mday, $mon, $year ) = localtime time;
  31.     if ( $mon < 10 ) {
  32.         $mon = "0" . ( $mon + 1 );
  33.     } else {
  34.         $mon = $mon + 1;
  35.     }
  36.     if ( $mday < 10 ) {
  37.         $mday = "0" . $mday;
  38.     }
  39.     my $opfile = sprintf "%s_%s_%s%s%s%s%s%s.txt",$uid,$fId,( $year + 1900 ),$mon,$mday,$hour,$min,$sec;
  40.  
  41.     #my $filename = $opfile;
  42.     #$filename =~ s/.*[\/\\](.*)/$1/;
  43.     #open UPLOADFILE, ">$upload_dir/$filename" or die "cannot open $filename: $!";;
  44.     #print UPLOADFILE "$data";
  45.     #close UPLOADFILE;
  46.     return $opfile;
  47. }
  48.  
  49. sub extraheaders {
  50.     warn 'extraheaders';
  51.     my $self = shift;
  52.     my ($q) = @{$self}{'query'};
  53.     my %headers;
  54.     if (defined($q->param('confirm'))) {
  55.         $headers{'-attachment'} = &downloadFileName($self->{'formid'});
  56.         return %headers;
  57.     } #elsif (defined($q->param('confirmsend'))) {
  58.     # $headers{'-attachment'} = &downloadFileName($self->{'formid'});
  59.     # return %headers;
  60.     #}
  61.     else {
  62.         $self->SUPER::extraheaders(@_);
  63.     }
  64. }
  65.  
  66. =item contenttype($q,$a)
  67.  
  68. contenttype is uses to set the MIME content-type HTTP header.
  69. set based on the request parameters - when a file download is requested
  70.  
  71. =cut
  72.  
  73. sub contenttype { warn 'contenttype';
  74.     my $self = shift;
  75.     my $q = shift;
  76.     my $a = shift;
  77.  
  78. # initialize the state
  79.     $self->initializeProcess($q);
  80.  
  81.     if ($self->{'download'}) {
  82.         return "text/plain";
  83.     }
  84.  
  85.     $self->SUPER::contenttype(@_);
  86. }
  87.  
  88.  
Hope this much will help me for shutting out the problem.

Thanks,
Chittaranjan
Apr 10 '07 #5
KevinADC
4,059 Expert 2GB
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.
Apr 10 '07 #6
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:)
Apr 11 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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 ?
1
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...
1
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...
6
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)...
0
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....
0
andrewsteed
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...
1
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...
0
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...
5
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
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...
0
jinu1996
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...
0
tracyyun
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.