XUpload - write comment onto a txt file after upload is done
-
- Posts: 15
- Joined: Apr 06, 2007 3:14 am
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?
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
Sure. Here goes quick hack to create Filename.txt text file with comment string inside:
in upload.cgi add this code after "&SaveFile(....);"
in upload.cgi add this code after "&SaveFile(....);"
Code: Select all
open(FILE,">$c->{target_dir}/$fhash{file_name}.txt");
print FILE $fhash{file_descr};
close FILE;
-
- Posts: 15
- Joined: Apr 06, 2007 3:14 am
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
Value assigned inb this line above:
where $k is file field name
Code: Select all
$fhash{file_descr} = $cg->param("$k\_descr");
-
- Posts: 15
- Joined: Apr 06, 2007 3:14 am
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
You have error in upload.cgi. Check out your Apache logs for details. I think it's cause you edited it in some windows editor and saved file with windows linebreaks.
Read http://www.sibsoft.net/forum/read-this- ... k-t84.html, number 3.
Read http://www.sibsoft.net/forum/read-this- ... k-t84.html, number 3.
-
- Posts: 15
- Joined: Apr 06, 2007 3:14 am
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
Ok. I've made special online tool for this: http://sibsoft.net/cgi-bin/Tools/nl.cgi
Just select your target file and click the button
Just select your target file and click the button
-
- Posts: 15
- Joined: Apr 06, 2007 3:14 am
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
Oh, ok then. Then replace old quick hack code in the same place to
here I used text field with name="comment", you can use any name.
Code: Select all
open(FILE,">$c->{target_dir}/$fn.txt");
print FILE $cg->param('comment');
close FILE;
-
- Posts: 15
- Joined: Apr 06, 2007 3:14 am
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
Replace
with
Code: Select all
print FILE $cg->param('comment');
Code: Select all
print FILE join(',', map{$cg->param($_)} qw(comment name emailaddress) );
-
- Posts: 15
- Joined: Apr 06, 2007 3:14 am