CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
need help writing file in htdocs folder

 



gerble1000
User

Dec 23, 2011, 1:08 AM

Post #1 of 14 (1531 views)
need help writing file in htdocs folder Can't Post

i am having trouble puting an image into the htdocs folder.
a can get it into cgi-bin fine.. here is my code


Code
$CGI::POST_MAX = 1024 * 50000;  
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "testfolder";

my $query = new CGI; my $filename = $query->param("uploadfile1");

my $upload_filehandle = $query->upload("uploadfile1");
open ( UPLOADFILE, ">$upload_dir/1.jpg" ) or die "$!"; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE;


and this is the actual windows path to my htdoct
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\

can you give me the sintax to put in please


rovf
Veteran

Dec 23, 2011, 5:31 AM

Post #2 of 14 (1530 views)
Re: [gerble1000] need help writing file in htdocs folder [In reply to] Can't Post


Quote
i am having trouble puting an image into the htdocs folder.


What kind of trouble? Does a small green monster appear and hit you on the head? ;-)

Please be more precise with your question...


gerble1000
User

Dec 23, 2011, 6:21 AM

Post #3 of 14 (1527 views)
Re: [rovf] need help writing file in htdocs folder [In reply to] Can't Post

i mean i put the full path of htdocs in and it does not place the uploaded image into that folder.
i might be puting the full path in wrong.
if you wer going to do it how would you go about this


FishMonger
Veteran / Moderator

Dec 23, 2011, 7:15 AM

Post #4 of 14 (1523 views)
Re: [gerble1000] need help writing file in htdocs folder [In reply to] Can't Post

What does the error message say?


gerble1000
User

Dec 23, 2011, 7:37 AM

Post #5 of 14 (1520 views)
Re: [FishMonger] need help writing file in htdocs folder [In reply to] Can't Post

just an error 500


FishMonger
Veteran / Moderator

Dec 23, 2011, 7:45 AM

Post #6 of 14 (1516 views)
Re: [gerble1000] need help writing file in htdocs folder [In reply to] Can't Post

You need to check the web server error log and/or add this line near the beginning of the script.

Code
use CGI::Carp qw(fatalsToBrowser);


And, you should change the die statement to this:

Code
die "failed to open '$upload_dir/1.jpg' $!"



rovf
Veteran

Dec 23, 2011, 1:20 PM

Post #7 of 14 (1511 views)
Re: [gerble1000] need help writing file in htdocs folder [In reply to] Can't Post

Not the server error - I mean: Did the "open" call fail (and,if yes, what's the error message)?


gerble1000
User

Dec 23, 2011, 1:37 PM

Post #8 of 14 (1507 views)
Re: [rovf] need help writing file in htdocs folder [In reply to] Can't Post

sorry i dont know what you mean, the only way i know of seeing an error with perl is when i submit the form and see what message i get and i get


gerble1000
User

Dec 23, 2011, 1:38 PM

Post #9 of 14 (1506 views)
Re: [rovf] need help writing file in htdocs folder [In reply to] Can't Post

also i have enabled fatal to browser and added the die string


gerble1000
User

Dec 23, 2011, 1:42 PM

Post #10 of 14 (1505 views)
Re: [gerble1000] need help writing file in htdocs folder [In reply to] Can't Post

i am such a knob head,,, it was because the slashes were the wrong way around..thanx anyway guys


rovf
Veteran

Dec 23, 2011, 2:16 PM

Post #11 of 14 (1501 views)
Re: [gerble1000] need help writing file in htdocs folder [In reply to] Can't Post

It doesn't make sense to provide output in your program, if you don't look at it. You have a "die" statement, which, when executed, writes to stderr. You need this message to diagnose the problem.


gerble1000
User

Dec 24, 2011, 7:36 AM

Post #12 of 14 (1492 views)
Re: [rovf] need help writing file in htdocs folder [In reply to] Can't Post

im not as good as you guys obviously.
im the sort of programmer that takes someone elses code and play with it. thats how i learn.
but yea you probably right as i dont allways look at the die.errors much.
im getting the hang of all this though :)


rovf
Veteran

Dec 24, 2011, 7:45 AM

Post #13 of 14 (1491 views)
Re: [gerble1000] need help writing file in htdocs folder [In reply to] Can't Post

I don't have experience with CGI programs, but maybe you should redirect stderr to a file, so that you can look at the messages.


FishMonger
Veteran / Moderator

Dec 24, 2011, 9:21 AM

Post #14 of 14 (1484 views)
Re: [rovf] need help writing file in htdocs folder [In reply to] Can't Post

The preferred method, in most cases, of debugging cgi scripts during development is to use CGI::Carp or one of the related modules.

http://search.cpan.org/search?query=cgi%3A%3Acarp&mode=all

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives