| View previous topic :: View next topic |
| Author |
Message |
drumcritic
Joined: 06 Apr 2007 Posts: 15
|
Posted: Apr 06, 2007 3:17 am Post subject: write comment onto a txt file after upload is done |
|
|
| is it possible to write the comment that the user inputed in the submit form onto a txt file after the upload transfer is complete? |
|
| Back to top |
|
 |
PilgrimX182

Joined: 22 Mar 2006 Posts: 2106 Location: UFO Lab
|
Posted: Apr 06, 2007 6:21 am Post subject: |
|
|
Sure. Here goes quick hack to create Filename.txt text file with comment string inside:
in upload.cgi add this code after "&SaveFile(....);"
| Code: | open(FILE,">$c->{target_dir}/$fhash{file_name}.txt");
print FILE $fhash{file_descr};
close FILE; |
|
|
| Back to top |
|
 |
drumcritic
Joined: 06 Apr 2007 Posts: 15
|
Posted: Apr 07, 2007 9:36 pm Post subject: |
|
|
| is the variable 'file_descr' an already assigned variable? if so, where was the value assigned? I want to know because I want to write other input fields into the text file as well. |
|
| Back to top |
|
 |
PilgrimX182

Joined: 22 Mar 2006 Posts: 2106 Location: UFO Lab
|
Posted: Apr 09, 2007 5:25 am Post subject: |
|
|
Value assigned inb this line above:
| Code: | | $fhash{file_descr} = $cg->param("$k\_descr"); |
where $k is file field name |
|
| Back to top |
|
 |
drumcritic
Joined: 06 Apr 2007 Posts: 15
|
Posted: Apr 15, 2007 12:59 am Post subject: |
|
|
um... I added the 3 lines of code to upload.cgi and now when I try to upload, the upload status window says "transfer complete!" without even uploading it and the parent window says "Internal Server Error".
help! |
|
| Back to top |
|
 |
PilgrimX182

Joined: 22 Mar 2006 Posts: 2106 Location: UFO Lab
|
|
| Back to top |
|
 |
drumcritic
Joined: 06 Apr 2007 Posts: 15
|
Posted: Apr 19, 2007 9:45 pm Post subject: |
|
|
| when I try to run "newline.exe" the dos window opens for a split second and then closes. what am I doing wrong? |
|
| Back to top |
|
 |
PilgrimX182

Joined: 22 Mar 2006 Posts: 2106 Location: UFO Lab
|
|
| Back to top |
|
 |
drumcritic
Joined: 06 Apr 2007 Posts: 15
|
Posted: Apr 21, 2007 10:45 pm Post subject: |
|
|
um... it still doesn't work :p
the newline works when I don't put in the 3 lines of code but it doesn't work once i put in the code.
do I just need "newline" or do I also need to do a "detab" as well? cause all of the win32 dos programs don't work :p |
|
| Back to top |
|
 |
PilgrimX182

Joined: 22 Mar 2006 Posts: 2106 Location: UFO Lab
|
Posted: Apr 23, 2007 6:06 am Post subject: |
|
|
Then the error is inside upload.cgi code. Free or Pro xupload version?
I gave solition for Pro one. You can PM me ftp access to xupload folder so I can fix it quickly. |
|
| Back to top |
|
 |
drumcritic
Joined: 06 Apr 2007 Posts: 15
|
Posted: Apr 23, 2007 7:11 pm Post subject: |
|
|
| it's free. |
|
| Back to top |
|
 |
PilgrimX182

Joined: 22 Mar 2006 Posts: 2106 Location: UFO Lab
|
Posted: Apr 24, 2007 5:22 am Post subject: |
|
|
Oh, ok then. Then replace old quick hack code in the same place to
| Code: | open(FILE,">$c->{target_dir}/$fn.txt");
print FILE $cg->param('comment');
close FILE; |
here I used text field with name="comment", you can use any name. |
|
| Back to top |
|
 |
drumcritic
Joined: 06 Apr 2007 Posts: 15
|
Posted: Apr 24, 2007 9:05 pm Post subject: |
|
|
how would you print multiple fields into the text file all split with a comma? ex. "comment,name,emailaddress,etc."
thx a lot! |
|
| Back to top |
|
 |
PilgrimX182

Joined: 22 Mar 2006 Posts: 2106 Location: UFO Lab
|
Posted: Apr 25, 2007 5:25 am Post subject: |
|
|
Replace
| Code: | | print FILE $cg->param('comment'); |
with
| Code: | | print FILE join(',', map{$cg->param($_)} qw(comment name emailaddress) ); |
|
|
| Back to top |
|
 |
drumcritic
Joined: 06 Apr 2007 Posts: 15
|
Posted: Jun 05, 2007 1:59 pm Post subject: |
|
|
heh, sorry for reopening this thread
um, is it possible for me to enclose all fields in the text with quotation marks?
thanks! |
|
| Back to top |
|
 |
|