Jeffrey Kesselman | 12 Jan 2011 04:22

[webmin-devel] Example of using ui_upload?

I want to only allow my users to upload and delte fiels from specific directories so I am building my own file management interface.


Is there a minimal working example of both setting up the ui_upload interface and handling the resulting form-data?

Its all a bit greek to me right at the moment...

Thanks

JK
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel
Jamie Cameron | 12 Jan 2011 05:09

Re: [webmin-devel] Example of using ui_upload?

On 11/Jan/2011 19:22 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..
> I want to only allow my users to upload and delte fiels from specific
> directories so I am building my own file management interface.
> 
> Is there a minimal working example of both setting up the ui_upload
> interface and handling the resulting form-data?
> 
> Its all a bit greek to me right at the moment...

The code for the form would be like :

print ui_form_start("upload.cgi", "form-data");
print "Choose a file : ",ui_upload("file");
print ui_form_end([ [ "ok", "Upload" ] ]);

And for the parser upload.cgi :

ReadParseMime();
open(FILE, ">/path/to/destfile");
print FILE $in{'file'};
close(FILE);

 - Jamie

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel

Jeffrey Kesselman | 12 Jan 2011 15:48

Re: [webmin-devel] Example of using ui_upload?

Perfect!  Thanks so much, Jamie!


Regards

jeff K

On Tue, Jan 11, 2011 at 11:09 PM, Jamie Cameron <jcameron <at> webmin.com> wrote:
On 11/Jan/2011 19:22 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..
> I want to only allow my users to upload and delte fiels from specific
> directories so I am building my own file management interface.
>
> Is there a minimal working example of both setting up the ui_upload
> interface and handling the resulting form-data?
>
> Its all a bit greek to me right at the moment...

The code for the form would be like :

print ui_form_start("upload.cgi", "form-data");
print "Choose a file : ",ui_upload("file");
print ui_form_end([ [ "ok", "Upload" ] ]);

And for the parser upload.cgi :

ReadParseMime();
open(FILE, ">/path/to/destfile");
print FILE $in{'file'};
close(FILE);

 - Jamie

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel
Jeffrey Kesselman | 12 Jan 2011 16:03

Re: [webmin-devel] Example of using ui_upload?

One more stupid Q sorry, how do I fetch the name of the uploaded file?  Is it another key on $in?

On Tue, Jan 11, 2011 at 11:09 PM, Jamie Cameron <jcameron <at> webmin.com> wrote:
On 11/Jan/2011 19:22 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..
> I want to only allow my users to upload and delte fiels from specific
> directories so I am building my own file management interface.
>
> Is there a minimal working example of both setting up the ui_upload
> interface and handling the resulting form-data?
>
> Its all a bit greek to me right at the moment...

The code for the form would be like :

print ui_form_start("upload.cgi", "form-data");
print "Choose a file : ",ui_upload("file");
print ui_form_end([ [ "ok", "Upload" ] ]);

And for the parser upload.cgi :

ReadParseMime();
open(FILE, ">/path/to/destfile");
print FILE $in{'file'};
close(FILE);

 - Jamie

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel
Jeffrey Kesselman | 12 Jan 2011 16:22

Re: [webmin-devel] Example of using ui_upload?

Hmm. ReadParseMime() is giving me a "Error - Missing Headers".  Im sure Im doing something stupid but I've been over it 3 times.


This is my submit code (pardon the commented out lines pls):

#!/opt/local/bin/perl

require 'nphos-lib.pl';

#my $bodyTags= "onLoad=window.setTimeout('window.location.reload()',10*1000);";
ui_print_header('RedDwarf Deployment Directory', 'NPHOS', '',undef,0,0,0,undef,u
ndef,$bodyTags,undef);
#print ui_form_start('delete_deployed.cgi','post');
#print ui_columns_start(["Select","File name"]);
#my <at> filenames = list_directory("/opt/local/reddwarf/10.2.1/deploy");
#foreach $filename ( <at> filenames){
#   ui_checked_columns_row($filename,undef,'file_select_check',$filename);
#}
#print ui_columns_end();
#print ui_form_end([[undef,"Delete checked files"]]);
#print ui_hr();
#print ui_subheading('File Upload');
print ui_form_start("upload_deployed.cgi","form-data");
print ui_upload("upload_file");
print ui_form_end([["ok","Upload file"]]);
ui_print_footer(undef,"NPHOS Platform page");


And this is upload_deployed.cgi:

#!/opt/local/bin/perl

require 'nphos-lib.pl';

ReadParseMime();
#my $filename = $in{'filename'};
#open(FILE, "/opt/local/reddwarf/10.2.1/deploy/$filename");
#print FILE $in{'upload_file'};
#close(FILE);


On Wed, Jan 12, 2011 at 10:03 AM, Jeffrey Kesselman <jeffpk <at> nphos.com> wrote:
One more stupid Q sorry, how do I fetch the name of the uploaded file?  Is it another key on $in?

On Tue, Jan 11, 2011 at 11:09 PM, Jamie Cameron <jcameron <at> webmin.com> wrote:
On 11/Jan/2011 19:22 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..
> I want to only allow my users to upload and delte fiels from specific
> directories so I am building my own file management interface.
>
> Is there a minimal working example of both setting up the ui_upload
> interface and handling the resulting form-data?
>
> Its all a bit greek to me right at the moment...

The code for the form would be like :

print ui_form_start("upload.cgi", "form-data");
print "Choose a file : ",ui_upload("file");
print ui_form_end([ [ "ok", "Upload" ] ]);

And for the parser upload.cgi :

ReadParseMime();
open(FILE, ">/path/to/destfile");
print FILE $in{'file'};
close(FILE);

 - Jamie

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel
Jamie Cameron | 12 Jan 2011 19:29

Re: [webmin-devel] Example of using ui_upload?

Does the upload_deployed.cgi script output anything, or call redirect ? If a webmin script doesn't call ui_print_header or redirect , you will get that error message .. 

On 12/Jan/2011 07:22 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..

Hmm. ReadParseMime() is giving me a "Error - Missing Headers".  Im sure Im doing something stupid but I've been over it 3 times.

This is my submit code (pardon the commented out lines pls):

#!/opt/local/bin/perl

require 'nphos-lib.pl';

#my $bodyTags= "xonLoad=window.setTimeout('window.location.reload()',10*1000);";
ui_print_header('RedDwarf Deployment Directory', 'NPHOS', '',undef,0,0,0,undef,u
ndef,$bodyTags,undef);
#print ui_form_start('delete_deployed.cgi','post');
#print ui_columns_start(["Select","File name"]);
#my <at> filenames = list_directory("/opt/local/reddwarf/10.2.1/deploy");
#foreach $filename ( <at> filenames){
#   ui_checked_columns_row($filename,undef,'file_select_check',$filename);
#}
#print ui_columns_end();
#print ui_form_end([[undef,"Delete checked files"]]);
#print ui_hr();
#print ui_subheading('File Upload');
print ui_form_start("upload_deployed.cgi","form-data");
print ui_upload("upload_file");
print ui_form_end([["ok","Upload file"]]);
ui_print_footer(undef,"NPHOS Platform page");


And this is upload_deployed.cgi:

#!/opt/local/bin/perl

require 'nphos-lib.pl';

ReadParseMime();
#my $filename = $in{'filename'};
#open(FILE, "/opt/local/reddwarf/10.2.1/deploy/$filename");
#print FILE $in{'upload_file'};
#close(FILE);


On Wed, Jan 12, 2011 at 10:03 AM, Jeffrey Kesselman <jeffpk <at> nphos.com> wrote:
One more stupid Q sorry, how do I fetch the name of the uploaded file?  Is it another key on $in?

On Tue, Jan 11, 2011 at 11:09 PM, Jamie Cameron <jcameron <at> webmin.com> wrote:
On 11/Jan/2011 19:22 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..
> I want to only allow my users to upload and delte fiels from specific
> directories so I am building my own file management interface.
>
> Is there a minimal working example of both setting up the ui_upload
> interface and handling the resulting form-data?
>
> Its all a bit greek to me right at the moment...

The code for the form would be like :

print ui_form_start("upload.cgi", "form-data");
print "Choose a file : ",ui_upload("file");
print ui_form_end([ [ "ok", "Upload" ] ]);

And for the parser upload.cgi :

ReadParseMime();
open(FILE, ">/path/to/destfile");
print FILE $in{'file'};
close(FILE);

 - Jamie

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel



------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel
Jamie Cameron | 12 Jan 2011 19:25

Re: [webmin-devel] Example of using ui_upload?

You can find it in :

$in{'file_filename'}

 - Jamie 

On 12/Jan/2011 07:03 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..

One more stupid Q sorry, how do I fetch the name of the uploaded file?  Is it another key on $in?

On Tue, Jan 11, 2011 at 11:09 PM, Jamie Cameron <jcameron <at> webmin.com> wrote:
On 11/Jan/2011 19:22 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..
> I want to only allow my users to upload and delte fiels from specific
> directories so I am building my own file management interface.
>
> Is there a minimal working example of both setting up the ui_upload
> interface and handling the resulting form-data?
>
> Its all a bit greek to me right at the moment...

The code for the form would be like :

print ui_form_start("upload.cgi", "form-data");
print "Choose a file : ",ui_upload("file");
print ui_form_end([ [ "ok", "Upload" ] ]);

And for the parser upload.cgi :

ReadParseMime();
open(FILE, ">/path/to/destfile");
print FILE $in{'file'};
close(FILE);

 - Jamie

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel
Jeffrey Kesselman | 12 Jan 2011 19:27

Re: [webmin-devel] Example of using ui_upload?

Thanks.  i just figured my other problem out.


Its because I wasn't giving it any ht5ml to display when done :)

On Wed, Jan 12, 2011 at 1:25 PM, Jamie Cameron <jcameron <at> webmin.com> wrote:

You can find it in :

$in{'file_filename'}

 - Jamie 

On 12/Jan/2011 07:03 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..

One more stupid Q sorry, how do I fetch the name of the uploaded file?  Is it another key on $in?

On Tue, Jan 11, 2011 at 11:09 PM, Jamie Cameron <jcameron <at> webmin.com> wrote:
On 11/Jan/2011 19:22 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..
> I want to only allow my users to upload and delte fiels from specific
> directories so I am building my own file management interface.
>
> Is there a minimal working example of both setting up the ui_upload
> interface and handling the resulting form-data?
>
> Its all a bit greek to me right at the moment...

The code for the form would be like :

print ui_form_start("upload.cgi", "form-data");
print "Choose a file : ",ui_upload("file");
print ui_form_end([ [ "ok", "Upload" ] ]);

And for the parser upload.cgi :

ReadParseMime();
open(FILE, ">/path/to/destfile");
print FILE $in{'file'};
close(FILE);

 - Jamie

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel



------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel
Jeffrey Kesselman | 12 Jan 2011 19:49

Re: [webmin-devel] Example of using ui_upload?

hmm...


this.:

ReadParseMime();
my $filename = $in{'file_filename'};

is resulting in $filename being empty :(

Any thoughts?  full code below...

#!/opt/local/bin/perl

require 'nphos-lib.pl';

ReadParseMime();
my $filename = $in{'file_filename'};
my $filepath = "/opt/local/reddwarf/10.2.1/deploy/$filename";
ui_print_header(undef, 'NPHOS', '',undef,0,0,0,undef,undef,$bodyTags,undef);
if (!open(FILE,$filepath)){
   print ui_subheading("Error uploadinh file $filepath: $error");
} else {
   print FILE $in{'upload_file'};
   close(FILE);
   redirect("reddwarf_deploy.cgi");
   print ui_subheading("Uploaded file $filename");
}
ui_print_footer(undef,"Manage Deployment");



On Wed, Jan 12, 2011 at 1:25 PM, Jamie Cameron <jcameron <at> webmin.com> wrote:

You can find it in :

$in{'file_filename'}

 - Jamie 

On 12/Jan/2011 07:03 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..

One more stupid Q sorry, how do I fetch the name of the uploaded file?  Is it another key on $in?

On Tue, Jan 11, 2011 at 11:09 PM, Jamie Cameron <jcameron <at> webmin.com> wrote:
On 11/Jan/2011 19:22 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..
> I want to only allow my users to upload and delte fiels from specific
> directories so I am building my own file management interface.
>
> Is there a minimal working example of both setting up the ui_upload
> interface and handling the resulting form-data?
>
> Its all a bit greek to me right at the moment...

The code for the form would be like :

print ui_form_start("upload.cgi", "form-data");
print "Choose a file : ",ui_upload("file");
print ui_form_end([ [ "ok", "Upload" ] ]);

And for the parser upload.cgi :

ReadParseMime();
open(FILE, ">/path/to/destfile");
print FILE $in{'file'};
close(FILE);

 - Jamie

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel



------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel
Jamie Cameron | 12 Jan 2011 20:01

Re: [webmin-devel] Example of using ui_upload?

You'd need to use $in{'upload_filename'} .

Basically, if the data being uploaded is in X then the filename will be in X_filename. 

On 12/Jan/2011 10:49 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..

hmm...

this.:

ReadParseMime();
my $filename = $in{'file_filename'};

is resulting in $filename being empty :(

Any thoughts?  full code below...

#!/opt/local/bin/perl

require 'nphos-lib.pl';

ReadParseMime();
my $filename = $in{'file_filename'};
my $filepath = "/opt/local/reddwarf/10.2.1/deploy/$filename";
ui_print_header(undef, 'NPHOS', '',undef,0,0,0,undef,undef,$bodyTags,undef);
if (!open(FILE,$filepath)){
   print ui_subheading("Error uploadinh file $filepath: $error");
} else {
   print FILE $in{'upload_file'};
   close(FILE);
   redirect("reddwarf_deploy.cgi");
   print ui_subheading("Uploaded file $filename");
}
ui_print_footer(undef,"Manage Deployment");



On Wed, Jan 12, 2011 at 1:25 PM, Jamie Cameron <jcameron <at> webmin.com> wrote:

You can find it in :

$in{'file_filename'}

 - Jamie 

On 12/Jan/2011 07:03 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..

One more stupid Q sorry, how do I fetch the name of the uploaded file?  Is it another key on $in?

On Tue, Jan 11, 2011 at 11:09 PM, Jamie Cameron <jcameron <at> webmin.com> wrote:
On 11/Jan/2011 19:22 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..
> I want to only allow my users to upload and delte fiels from specific
> directories so I am building my own file management interface.
>
> Is there a minimal working example of both setting up the ui_upload
> interface and handling the resulting form-data?
>
> Its all a bit greek to me right at the moment...

The code for the form would be like :

print ui_form_start("upload.cgi", "form-data");
print "Choose a file : ",ui_upload("file");
print ui_form_end([ [ "ok", "Upload" ] ]);

And for the parser upload.cgi :

ReadParseMime();
open(FILE, ">/path/to/destfile");
print FILE $in{'file'};
close(FILE);

 - Jamie

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel



------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel



------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel
Jeffrey Kesselman | 12 Jan 2011 20:34

Re: [webmin-devel] Example of using ui_upload?

ahhh.  got it,  thank you.


Sorry to be a pain.  I really appreciate the pointers.

JK

On Wed, Jan 12, 2011 at 2:01 PM, Jamie Cameron <jcameron <at> webmin.com> wrote:

You'd need to use $in{'upload_filename'} .

Basically, if the data being uploaded is in X then the filename will be in X_filename. 

On 12/Jan/2011 10:49 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..

hmm...

this.:

ReadParseMime();
my $filename = $in{'file_filename'};

is resulting in $filename being empty :(

Any thoughts?  full code below...

#!/opt/local/bin/perl

require 'nphos-lib.pl';

ReadParseMime();
my $filename = $in{'file_filename'};
my $filepath = "/opt/local/reddwarf/10.2.1/deploy/$filename";
ui_print_header(undef, 'NPHOS', '',undef,0,0,0,undef,undef,$bodyTags,undef);
if (!open(FILE,$filepath)){
   print ui_subheading("Error uploadinh file $filepath: $error");
} else {
   print FILE $in{'upload_file'};
   close(FILE);
   redirect("reddwarf_deploy.cgi");
   print ui_subheading("Uploaded file $filename");
}
ui_print_footer(undef,"Manage Deployment");



On Wed, Jan 12, 2011 at 1:25 PM, Jamie Cameron <jcameron <at> webmin.com> wrote:

You can find it in :

$in{'file_filename'}

 - Jamie 

On 12/Jan/2011 07:03 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..

One more stupid Q sorry, how do I fetch the name of the uploaded file?  Is it another key on $in?

On Tue, Jan 11, 2011 at 11:09 PM, Jamie Cameron <jcameron <at> webmin.com> wrote:
On 11/Jan/2011 19:22 Jeffrey Kesselman <jeffpk <at> nphos.com> wrote ..
> I want to only allow my users to upload and delte fiels from specific
> directories so I am building my own file management interface.
>
> Is there a minimal working example of both setting up the ui_upload
> interface and handling the resulting form-data?
>
> Its all a bit greek to me right at the moment...

The code for the form would be like :

print ui_form_start("upload.cgi", "form-data");
print "Choose a file : ",ui_upload("file");
print ui_form_end([ [ "ok", "Upload" ] ]);

And for the parser upload.cgi :

ReadParseMime();
open(FILE, ">/path/to/destfile");
print FILE $in{'file'};
close(FILE);

 - Jamie

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel



------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel




------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-
Forwarded by the Webmin development list at webmin-devel <at> webmin.com
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel

Gmane