Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old September 6th, 1999, 11:23 AM
miguelgarcia
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I am looking for a way to give users the ability to uplaod files. (html, gif's and jpg's).

The idea is that I want user to be able to upload html documents, along with any referenced images.

There will probably be some java/javascript necesary to get it done, but there has to be some code samples out there somewhere. Anyone have any ideas.

The help I've received so far has been very appreciated.

Reply With Quote
  #2  
Old September 7th, 1999, 08:33 AM
Projecto EINet
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Try to use PHP3 if you can. It's very easy.

Goto http://www.cgi-resources.com and see some Web Advert programs in Perl. It's a kind of program that usually uses Upload for banners.

Another place is http://www.scriptsearch.com. They have a lot of samples too.


Reply With Quote
  #3  
Old September 20th, 1999, 01:36 PM
Imo
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
perldoc CGI

(The CGI module for perl). In there you'll find:

print $query->filefield('uploaded_file','starting value',50,80);

And more information.

Reply With Quote
  #4  
Old October 27th, 1999, 12:44 AM
AjayLulia
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I have used a program i am sending to u

check the file the file is below

#This script is used to upload a file where it is a Txt for a binary file
#coz the file is opend first through open function and then changed the mode using
# a function binmode().
###################################################################################
#
#Author: Ajay Lulia
#E-Mail: ajaylulia@hotmail.com
#
###################################################################################
BEGIN {
$userid = "ID_number"; # --> This Number is the specific ID
# --> ID number assigned to you on your
# --> Unix System.

$groupid = "ID_number"; # --> This Number is the specific Group
# --> ID number assigned to people with
# --> your access level on your Unix
# --> system.

#
# --> You can gain your $userid and
# --> $groupid by typing 'id' at your
# --> UNIX prompt. (GID = Group Id,
# --> UID = User Id).


$path = "c:/netscape/suitespot/ksdocs/publications/";
#
# --> The $path variable should contain the
# --> directory that this script will place
# --> uploaded files into. It should NOT have
# --> a trailing forward slash.

$url = "ftp://proto.kotaksec.com/publications/";
#
# --> $url should be the URL which corresponds
# --> to the $path defined above. And same
# --> as the $path variable, it SHOULD NOT
# --> have a trailing forward slash.

$overwrite = "1"; # --> Set this value to '1' to allow
# --> overwriting of existing files.
# --> Set this value to '0' to dis-allow
# --> the overwriting of existing files.
# -->
# --> NOTE:
# --> Existing files WILL NOT be over-
# --> written unless they are given the
# --> permissions 'a+rw'. An error message
# --> will return to users who try to over-
# --> write files which are protected.

$success_url = "http://proto.kotaksec.com/admin/upload_doc_right.html";
#
# --> This contains the URL people should be
# --> redirected to once they have completed
# --> a successful upload. If empty, a page
# --> will be generated, which includes
# --> statistics.

$exclusive_lock = 2; # --> DO NOT CHANGE THIS VALUE - It should
# --> be set to '2'

$unlock_lock = 8; # --> DO NOT CHANGE THIS VALUE - It should
# --> be set to '8'

$pub_path{'Morning Flash'} = "morningflash";
$pub_path{'Initiative Coverage Report'} = "icr";
$pub_path{'Company Updates'} = "companyupdates";
$pub_path{'Notes From'} = "notesfrom";
$pub_path{'Non Rated Coverage'} = "nrc";
$pub_path{'Sector Reports'} = "sectorreport";
$pub_path{'Strategy Reports'} = "strategyreport";
$pub_path{'Earnings Guide'} = "earningsguide";

}


#
# End of Configurable Options.
# ---------------------------------------------------------------------
# ---------------------------------------------------------------------
# --> Do Not Change Anything Below This Line. <-- #
# ---------------------------------------------------------------------
# ---------------------------------------------------------------------

$| = 1;


&GetInput;
&Process_File;
&Redirect_User;

# ---------------------------------------------------------------------
sub GetInput {
#
# --> Sub: &GetInput();
#
# --> Return:
#
# --> Summary:
# Loads CGI module, assigns $filename the filename the
# file should be saved as.
#

use CGI;
$query = new CGI;

$publication = $query->param('publication');

$path = $path.$pub_path{$publication};

$url = $url.$pub_path{$publication};


if ($query->param('save-as-filename') !~ /^[ t]*$/) {
$filename = $query->param('save-as-filename');
} else {
$filename = $query->param('upload_file');
}

#
# END OF SUB
#
}

# ---------------------------------------------------------------------

sub Process_File {
#
# --> Sub: &Process_File();
#
# --> Return:
#
# --> Summary:
# Takes all the input, determines if the user is using
# the appropiate browser, then extracts the filename,
# and saves the file. Uploaded files are chmodded to 644,
# and given ownership to the user defined in $userid and
# $groupid.
#

&Exit_Not_A_Netscape_User if ($ENV{'HTTP_USER_AGENT'} !~ /^Mozilla/[432]/);

if ($filename =~ ///) {
@array = split(///, $filename);
$real_name = pop(@array);
} elsif ($filename =~ //) {
@array = split(//, $filename);
$real_name = pop(@array);
} else {
$real_name = "$filename";
}

$outfile = "$path" . "/" . "$real_name";

$filename = $query->param('upload_file');

&Exit_File_Exists if ((-e "$outfile") && (!$overwrite));

if (!open(OUTFILE, ">$outfile")) {
print "Content-type: text/plainnn";
print "-------------------------n";
print "Error:n";
print "-------------------------n";
print "File: $outfilen";
print "-------------------------n";
print "There was an error opening the Output Filen";
print "for Writing.nn";
print "Make sure that the directory:n";
print "$pathn";
print "has been chmodded with the permissions '777'.nn";
print "Also, make sure that if your attemptingn";
print "to overwrite an existing file, that then";
print "existing file is chmodded '666' or better.nn";
print "The Error message below should help you diagnosen";
print "the problem.nn";
print "Error: $!n";
exit;
}
binmode(OUTFILE);
while ($bytesread = read($filename,$buffer,1024)) {
$totalbytes += $bytesread;
print OUTFILE $buffer;
}

close($filename);
close(OUTFILE);

# chmod (0644, "$outfile");
# chown ($userid, $groupid, "$outfile");

#
# END OF SUB
#
}

# ---------------------------------------------------------------------

sub Redirect_User {
#
# --> Sub: &Redirect_User();
#
# --> Return:
#
# --> Summary:
# Redirects users to the success url defined in
# $success_url the program then terminates.
#

if ($success_url) {
print "Location: $success_urlnnn";
#print "Content-type: text/htmlnn";
#print "$publication";
#print $pub_path{'Morning Flash'};
exit;
} else {
print "Content-type: text/htmlnn";
print <<END_OF_HTML_CODE;

<HTML>
<HEAD>
<TITLE>Thank You</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1><TT><B>Thank You</B></TT></H1><br>

END_OF_HTML_CODE

print "Thanks for the upload. You uploaded one file, which was $totalbytes bytes in size.n";
print "It has been saved. You can access it with the url: <a href="$url/$real_name">$url/$real_name</a>n";
print "<p><hr size=1><center>Script By <a href="mailto:jeffc@terminalp.com">Jeff Carnahan</a> of <a href="http://www.terminalp.com/scripts/">Jeff's Scripts</a></center></BODY></HTML>n";
exit;
}

#
# END OF SUB
#
}

# ---------------------------------------------------------------------

sub Exit_Not_A_Netscape_User {
#
# --> Sub: &Exit_Not_A_Netscape_User();
#
# --> Return:
#
# --> Summary:
# This user is not using a version of Netscape claiming
# to be above version 2.0...
#

print "Content-type: text/htmlnn";
print <<END_OF_HTML_CODE;

<HTML>
<HEAD>
<TITLE>Error!</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1><TT><B>Error! - Invalid Browser</B></TT></H1><br>
Sorry, but you must use Netscape 2.0+ to use this system. Please
use the back button on your browser and try again.
</BODY>
</HTML>

END_OF_HTML_CODE

exit;

#
# END OF SUB
#
}

# ---------------------------------------------------------------------


sub Exit_File_Exists {
#
# --> Sub: &Exit_File_Exists();
#
# --> Return:
#
# --> Summary:
# This user is trying to upload a file with a filename
# that is already in use, and this script is set not to
# overwrite existing files.
#

print "Content-type: text/htmlnn";
print <<END_OF_HTML_CODE;

<HTML>
<HEAD>
<TITLE>Error!</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1><TT><B>Error! - File Exists</B></TT></H1><br>
Sorry, but this system is not allowed to overwrite existing files. The filename
you have selected is already in use where file-uploads are allowed. Please use the
back button on your browser, rename the file and try again.
</BODY>
</HTML>

END_OF_HTML_CODE

exit;

#
# END OF SUB
#
}

# ---------------------------------------------------------------------
# EOF



------------------

Ajay Lulia.

Reply With Quote
  #5  
Old November 7th, 1999, 06:02 AM
thelem
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Can I have permission to use this script in a bigger script which may be sold please? If not I will find another way of doing it, I cannot afford to pay.

Thanks,
Lemming

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > How can I have a user upload files from web form


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway