473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

File Upload Script

hi all,
i have seen a program from web that is used to upload a file from particular directory..
My problem is that they have mentioned some file directory name in the program but when i am running the program, in the browser i am getting the directory is not valid..

In this program i have not involved to do any part,but i need to know about this code..

code for fileupload
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. print "content-type:text/html \n\n";
  4. print <<html_part;
  5. <html>
  6. <head>
  7. <script>
  8. function validate() {
  9.     if(document.test.file.value=="") {
  10.         alert("file name cannot be empty");
  11.         return;
  12.     }
  13.     document.test.submit(true);
  14. }
  15. </script>
  16. </head>
  17. <body>
  18. <FORM name="test" ENCTYPE="multipart/form-data" ACTION="upload.cgi" METHOD="POST">
  19. <p>
  20. Please select a file to upload: <INPUT TYPE="FILE" NAME="file">
  21. <p>
  22. <INPUT TYPE="button" value="submit_form" onclick="validate()">
  23. </FORM>
  24. </body>
  25. </html>
  26. html_part
  27.  
code for upload.cgi
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. print "content-type:text/html \n\n";
  3.  
  4. use CGI;
  5. my $cgi = new CGI;
  6.  
  7. my $file = $cgi->param('file');
  8. $file =~ m/^.*(\\|\/)(.*)/;
  9.  
  10. my $name = $2;
  11.  
  12. open(LOCAL, ">../sample/$name") or die $!;
  13. while(<$file>) {
  14.     print LOCAL $_;
  15. }
  16. print $cgi->header();
  17. print "$file has been successfully uploaded... thank you.\n";
  18.  

any help would be grateful..i can browse the file and attaching it, but it is not getting uploaded..
will u give me answer for this...
Jun 20 '07 #1
2 2026
KevinADC
4,059 Expert 2GB
I assume this line is the problem:

open(LOCAL, ">../sample/$name") or die $!;

"../sample" is just that, it is an example only. You need to change that to a valid directory on your server.
Jun 20 '07 #2
skyy
109 100+
Hi...

Make sure the folder exists in ur server and that the permission is allowed to write to the folder..
Jun 25 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tihon | last post by:
Hello! I again need your help, just can't understand whats going on. Got this upload pictures form and it's having problem handling large files (~1.5 - 2 MB). Everything works fine if i just...
15
by: Simon | last post by:
I would like to create a very basic file upload add image form to add to my web site and to keep them in a "tmp" directory within my web hosting file manager once uploaded. I understand the basic...
1
by: PeterB | last post by:
Hi! I'm using Pure ASP File Upload (http://www.asp101.com/articles/jacob/scriptupload.asp) to upload a file from a client to a server. I am testing both on a local IIS and a remote server. The...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
1
by: pbd22 | last post by:
hi. i have been posting this here and elsewhere a lot and can't seem to get resolution on this problem. i have been trying to upload files using a hidden iframe to a asp.net/vb.net form. the...
3
by: kksandeep | last post by:
i am using this three files to uplod file. i got this file from net but i think these have some error. i am new to this field plz help the script i found is some helpful but not too that i need ...
1
by: kksandeep | last post by:
i am using this three files to uplod file. i got this file from net but i think these have some error. i am new to this field plz help the script i found is some helpful but not too that i need ...
1
by: chrisj | last post by:
I'm using freeASPupload and got some assistance integrating to a Member script. It works successfully. In this modified version there are two groups that use this upload script. Members of one...
6
Jacotheron
by: Jacotheron | last post by:
I need a PHP script that can upload music files (mp3). The script is for a home project I have started a while ago. I have a MySQL database of all the music that I have. Other computers on the...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.