write comment onto a txt file after upload is done

XUpload related questions

Moderator: admin

Message
Author
drumcritic
Posts: 15
Joined: Apr 06, 2007 3:14 am

write comment onto a txt file after upload is done

#1 Postby drumcritic » Apr 06, 2007 3:17 am

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?

User avatar
PilgrimX182
Posts: 2181
Joined: Mar 22, 2006 1:39 pm
Location: UFO Lab
Contact:

#2 Postby PilgrimX182 » Apr 06, 2007 6:21 am

Sure. Here goes quick hack to create Filename.txt text file with comment string inside:

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;

drumcritic
Posts: 15
Joined: Apr 06, 2007 3:14 am

#3 Postby drumcritic » Apr 07, 2007 9:36 pm

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.

User avatar
PilgrimX182
Posts: 2181
Joined: Mar 22, 2006 1:39 pm
Location: UFO Lab
Contact:

#4 Postby PilgrimX182 » Apr 09, 2007 5:25 am

Value assigned inb this line above:

Code: Select all

$fhash{file_descr} = $cg->param("$k\_descr");


where $k is file field name

drumcritic
Posts: 15
Joined: Apr 06, 2007 3:14 am

#5 Postby drumcritic » Apr 15, 2007 12:59 am

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!

User avatar
PilgrimX182
Posts: 2181
Joined: Mar 22, 2006 1:39 pm
Location: UFO Lab
Contact:

#6 Postby PilgrimX182 » Apr 16, 2007 5:35 am

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.

drumcritic
Posts: 15
Joined: Apr 06, 2007 3:14 am

#7 Postby drumcritic » Apr 19, 2007 9:45 pm

when I try to run "newline.exe" the dos window opens for a split second and then closes. what am I doing wrong?

User avatar
PilgrimX182
Posts: 2181
Joined: Mar 22, 2006 1:39 pm
Location: UFO Lab
Contact:

#8 Postby PilgrimX182 » Apr 20, 2007 6:31 am

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

drumcritic
Posts: 15
Joined: Apr 06, 2007 3:14 am

#9 Postby drumcritic » Apr 21, 2007 10:45 pm

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

User avatar
PilgrimX182
Posts: 2181
Joined: Mar 22, 2006 1:39 pm
Location: UFO Lab
Contact:

#10 Postby PilgrimX182 » Apr 23, 2007 6:06 am

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.

drumcritic
Posts: 15
Joined: Apr 06, 2007 3:14 am

#11 Postby drumcritic » Apr 23, 2007 7:11 pm

it's free.

User avatar
PilgrimX182
Posts: 2181
Joined: Mar 22, 2006 1:39 pm
Location: UFO Lab
Contact:

#12 Postby PilgrimX182 » Apr 24, 2007 5:22 am

Oh, ok then. Then replace old quick hack code in the same place to

Code: Select all

   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.

drumcritic
Posts: 15
Joined: Apr 06, 2007 3:14 am

#13 Postby drumcritic » Apr 24, 2007 9:05 pm

how would you print multiple fields into the text file all split with a comma? ex. "comment,name,emailaddress,etc."
thx a lot!

User avatar
PilgrimX182
Posts: 2181
Joined: Mar 22, 2006 1:39 pm
Location: UFO Lab
Contact:

#14 Postby PilgrimX182 » Apr 25, 2007 5:25 am

Replace

Code: Select all

print FILE $cg->param('comment');


with

Code: Select all

print FILE join(',', map{$cg->param($_)} qw(comment name emailaddress) );

drumcritic
Posts: 15
Joined: Apr 06, 2007 3:14 am

#15 Postby drumcritic » Jun 05, 2007 1:59 pm

heh, sorry for reopening this thread

um, is it possible for me to enclose all fields in the text with quotation marks?

thanks!


Return to “XUpload”

Who is online

Users browsing this forum: No registered users and 0 guests