View Full Version : Help with an extra credit project...should be simple.
Sven33
12-08-2005, 06:00 AM
Where can I get some help on an extra credit assignment?
Thank You
_Aerospace_Eng_
12-08-2005, 06:16 AM
I advise that you read this (http://www.codingforums.com/showthread.php?t=53446). We aren't here to do your homework (extra credit) for you. We are here to help you. If you have something you have started we could tell you what you might have done wrong and give you some hints. Even if I was going to do your work for you which I'm not it would be worth more than the 5 - 10 dollars that you are willing to offer.
Sven33
12-09-2005, 09:17 PM
Here is my assignment: 1. Develop a CGI Image Gallery. Script or scripts should provide the ability to create directories to store images in. It should then provide the ability to upload images in png or jpg format only into those directories. Once images are upload.. it should provide a table view of all images in thumbnail scale, and all them to be clicked for full scale view.
Now, I'm on quite the time constraint, have no previous programming knowledge, and pretty much lost in this class. I'm a very good student when it comes to History/Latin/Int'l Business; however, I'm not smart enough to pick up programming. Regardless, I just want to get it over with.
Here's what I have so far (I sent it to the professor...I give up. Hopefully he'll give me some credit).
#!/perl/bin/perl -wT
#upload.pl
use strict;
use CGI ':standard';
print "Content-type: text/html\n\n";
#scripts combined.
form();
my @b = directoryList();
print "Directories";
foreach( @b ){
print "$_ <p>";
}
print @b;
listImages(@b);
if(param('but') eq 'Upload'){
uploadfile();
}
if(param('but') eq 'pictures'){
listImages(@b, param('directory'));
}
sub listImages{
my(@files, $directory) = $_;
my $size = @files;
for(my $i = 0; $i <= $size; $i++){
print qq(
<A HREF="../upload/$directory">
<IMG HEIGHT=150 WIDTH=150 SRC="../upload/$directory/$files[$i]"></A>
);
}
}
sub directoryList{
opendir (UPLOAD, "../upload/");
my @direc = readdir (UPLOAD) ;
closedir(UPLOAD);
return @direc
}
sub uploadfile{
opendir (UPLOAD, "../upload/");
my @array = readdir (UPLOAD) ;
print " Here is a list of my files<br><br> @array";
closedir(UPLOAD);
my $file = param ('upload');
my $info = uploadInfo ($file);
my $type = $info -> {'Content-Type'};
print $type; #images/jpg
if ($file) {
open (UPLOADFILE, "../upload/");
my ($data, $length, $chunk);
while ($chunk = read ($file, $data, 1024)) {
print UPLOADFILE $data;
$length += $chunk;
if ($length > 51200) {
print "That file is way too big; don't you know the limit is only 50k!?";
exit;
}
}
close (UPLOADFILE);
print "<p>You uploaded <b>$file</b> which had a MIME of <b>$type</b>.</p>";
} else {
print "No file was chosen.";
}
}
sub Error {
print "Couldn't open temporary file: $!";
exit;
}
sub form{
print qq(
<html>
<head>
<title>Blah</title>
</head>
<body>
<h1> Please Upload a form...that won't hack into my system.</h1>
<form action="../cgi-bin/upload_attempt.pl"
method="post" enctype="multipart/form-data">
What file are you going to hack into my system with?
<input type="file" name="uploadfile" size="40">
<input type="text" name="directory">
<input type="submit" VALUE="Upload" Name="but">
<input type="submit" VALUE="pictures" Name="but">
</form>
</body>
</html>
);
}
Can anybody help me....I know I have some configuration to do....but don't know how or where.
mlseim
12-09-2005, 11:31 PM
If programming is not your interest, and this assignment is just for
extra credit ... maybe you should find something else to do for extra credit.
I'm not trying to be a wise-guy here, I'm actually serious.
Not everyone wants to get into computer programming ...
I certainly wouldn't sew a dress for extra credit, not interested.
I wouldn't even start it, and then ask for help finishing.
Write a simple program that works, even if it's not what the professor wants.
Turn it in, explain to him that you have no interest in programming, and
take whatever grade he hands out.
How about this:
Write a simple program that translates some words from English to Latin.
Maybe the Latin Language combined with programming may be of more
interest to you.
Having someone else write the program for you really does you no good.
.
FishMonger
12-09-2005, 11:32 PM
Since this is a school project, I can't provide you with a corrected script, but I can direct you to a couple resources that will help.
Most of the info you need is in the documentation on the cgi module. Search for the section on the file upload function and the $CGI::POST_MAX setting. For creating the thumbnails, if your professor allows you to use modules of your choosing, take a look at some of the graphics modules.
http://search.cpan.org/~lds/CGI.pm-3.15/CGI.pm#CREATING_A_FILE_UPLOAD_FIELD
http://search.cpan.org/~lds/CGI.pm-3.15/CGI.pm#CREATING_A_FILE_UPLOAD_FIELD
http://search.cpan.org/search?query=thumbnail&mode=all
http://search.cpan.org/~lgoddard/Image-Thumbnail-0.5/Thumbnail.pm
http://search.cpan.org/~aroth/Image-Magick-Thumbnail-Fixed-0.04/Fixed.pm
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.