RegisterRegister    SearchSearch   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AJAX upload progress bar

File sharing script

File mirror script

Newsletter script
write comment onto a txt file after upload is done
Goto page 1, 2  Next
 
Post new topic   Reply to topic    SibSoft Ltd Forum Index -> XUpload
View previous topic :: View next topic  
Author Message
drumcritic



Joined: 06 Apr 2007
Posts: 15

PostPosted: Apr 06, 2007 3:17 am    Post subject: write comment onto a txt file after upload is done Reply with quote

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
View user's profile Send private message
PilgrimX182



Joined: 22 Mar 2006
Posts: 2106
Location: UFO Lab

PostPosted: Apr 06, 2007 6:21 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
drumcritic



Joined: 06 Apr 2007
Posts: 15

PostPosted: Apr 07, 2007 9:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
PilgrimX182



Joined: 22 Mar 2006
Posts: 2106
Location: UFO Lab

PostPosted: Apr 09, 2007 5:25 am    Post subject: Reply with quote

Value assigned inb this line above:
Code:
$fhash{file_descr} = $cg->param("$k\_descr");


where $k is file field name
Back to top
View user's profile Send private message Visit poster's website
drumcritic



Joined: 06 Apr 2007
Posts: 15

PostPosted: Apr 15, 2007 12:59 am    Post subject: Reply with quote

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
View user's profile Send private message
PilgrimX182



Joined: 22 Mar 2006
Posts: 2106
Location: UFO Lab

PostPosted: Apr 16, 2007 5:35 am    Post subject: Reply with quote

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-first-if-your-xupload-don-t-work-t84.html, number 3.
Back to top
View user's profile Send private message Visit poster's website
drumcritic



Joined: 06 Apr 2007
Posts: 15

PostPosted: Apr 19, 2007 9:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
PilgrimX182



Joined: 22 Mar 2006
Posts: 2106
Location: UFO Lab

PostPosted: Apr 20, 2007 6:31 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
drumcritic



Joined: 06 Apr 2007
Posts: 15

PostPosted: Apr 21, 2007 10:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
PilgrimX182



Joined: 22 Mar 2006
Posts: 2106
Location: UFO Lab

PostPosted: Apr 23, 2007 6:06 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
drumcritic



Joined: 06 Apr 2007
Posts: 15

PostPosted: Apr 23, 2007 7:11 pm    Post subject: Reply with quote

it's free.
Back to top
View user's profile Send private message
PilgrimX182



Joined: 22 Mar 2006
Posts: 2106
Location: UFO Lab

PostPosted: Apr 24, 2007 5:22 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
drumcritic



Joined: 06 Apr 2007
Posts: 15

PostPosted: Apr 24, 2007 9:05 pm    Post subject: Reply with quote

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
View user's profile Send private message
PilgrimX182



Joined: 22 Mar 2006
Posts: 2106
Location: UFO Lab

PostPosted: Apr 25, 2007 5:25 am    Post subject: Reply with quote

Replace

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


with

Code:
print FILE join(',', map{$cg->param($_)} qw(comment name emailaddress) );
Back to top
View user's profile Send private message Visit poster's website
drumcritic



Joined: 06 Apr 2007
Posts: 15

PostPosted: Jun 05, 2007 1:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SibSoft Ltd Forum Index -> XUpload All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group