uploading pictures
Results 1 to 4 of 4

Thread: uploading pictures

  1. #1
    Senior Member
    Join Date
    Jun 2004
    Posts
    281

    uploading pictures

    I am trying to figure out the easiest way and most effective way of creating this:

    I was asked to develop an area where people can type a story then upload a picture or pictures along with it. However the stories will not automatically be generated it will go into review and then when the story is reviewed it will be published. However, I would like to be able to build it into database form so that I can sort all those entered and so on.

    What do you guys think? This maybe unclear workin on only a few hours of work.


    - MilitantEidolon
    Yeah thats right........I said It!

    Ultimately everyone will have their own opinion--this is mine.

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,255

    Re: uploading pictures

    Originally posted here by MilitantEidolon
    What do you guys think? This maybe unclear workin on only a few hours of work.
    What do you have available to you, resource-wise? This can be done rather easily in PHP, ASP, or really any web language.
    Chris Shepherd
    The Nelson-Shepherd cutoff: The point at which you realise someone is an idiot while trying to help them.
    \"Well as far as the spelling, I speak fluently both your native languages. Do you even can try spell mine ?\" -- Failed Insult
    Is your whole family retarded, or did they just catch it from you?

  3. #3
    Jaded Network Admin nebulus200's Avatar
    Join Date
    Jun 2002
    Posts
    1,356
    here is something I did on a whim one day, it probably has risks, but here ya go (it was made for uploading screenshots from a game I play). I also was using it for something else and removed some of the safeguards.

    Code:
    #!/usr/bin/perl
    use CGI;
    
    $q = new CGI;
    
    print $q->header, $q->start_html(-title=>"Upload Results",-bgcolor=>"00aa00");
    print $q->h2("Upload Results");
    
    $file = $q->param("upfile");
    if(! $file )
    {
            print "I'm sorry, there appears to be an issue with uploading that file.  Try again.
    ";
            $q->end_html;
            exit 1;
    }
    
    $ctype = $q->uploadInfo($file)->{'Content-Type'};
    if (!$file) {
        print "Nothing uploaded?
    
    \n";
    } elsif ($ctype ne "image/gif" && $ctype ne "image/jpeg" && $ctype ne "image/pjpeg") {
        print "Only .gif and .jpeg files may be uploaded at this time.
    ";
        print "You tried to upload $ctype.
    ";
    } else {
        print "Filename: $file
    \n";
        $ctype = $q->uploadInfo($file)->{'Content-Type'};
        print "MIME Type: $ctype
    \n";
        open(OUT,">/tmp/outfile") or dienice("Can't open outfile for writing: $!");
        $flen = 0;
        while (read($file,$i,1024)) {
            print OUT $i;
            $flen = $flen + 1024;
            if ($flen > 600000) {
                close(OUT);
                dienice("Error - file is too large. Save aborted.
    
    ");
            }
        }
        close(OUT);
        print "Length: ",$flen/1024,"Kb
    
    \n";
        print "File saved!
    
    \n";
    # display the image. this only works because we have a symlink from
    # tmp.gif/jpeg in the current directory, to /tmp/outfile.
        my $time = time;
        if ($ctype eq "image/gif") {
            print "Here's what you sent (Reference it with http://yoruwebserver/screenshot-$time.gif):
    
    \n";
            `mv /tmp/outfile ./screenshot-$time.gif`;
            $_ = `file ./screenshot-$time.gif`;
            if ( ! m/GIF/) { `rm ./screenshot-$time.gif`; print "<FONT size=4 color=red>\n";
                    print "Tsk...tsk...tsk...you tried to trick me...I just told mommie...\n";
                    print "</font>";
            }
            else
            {
                    print "<img src=\"screenshot-$time.gif\" border=1>
    
    \n";
            }
        } elsif ($ctype eq "image/jpeg" || $ctype eq "image/pjpeg") {
            print "Here's what you sent (Reference it with http://yourwebserver/screenshot-$time.jpg):
    
    \n";
            `mv /tmp/outfile ./screenshot-$time.jpg`;
            $_ = `file ./screenshot-$time.jpg`;
            if ( ! m/JPEG/ && ! m/data/) { `rm ./screenshot-$time.jpg`; print "<FONT size=4 color=red>\n";
                    print "Tsk...tsk...tsk...you tried to trick me...I just told mommie...\n";
                    print "</font>";
            }
            else
            {
                    print "<img src=\"screenshot-$time.jpg\" border=1>
    
    \n";
            }
        }
    }
    
    $q->end_html;
    
    sub dienice {
        my($msg) = @_;
        print "<h2>Error</h2>\n";
        print "$msg
    
    \n";
        exit;
    }
    The HTML for it was here:
    Code:
    <html><head><title>X Picture Upload</title></head>
    <body bgcolor="white" text="blue">
    
    <h2>X Picture Upload</h2>
    <form method="post" action="upload.cgi" enctype="multipart/form-data">
    This form uploads a picture from your machine to the server. Enter the
    file name to upload: 
    
    
    
    
    <FONT color=red>ALL ACTIVITY IS LOGGED.  DO NOT POST LEWD, OBSCENE, OR LASCIVIOUS MATERIAL.
    
    You will be banned from access to this server and the material immediately deleted (and
    
    if the material is bad enough, potentially prosecuted)</p>
    </font>
    
    200kB filesize limit
    
    <input type="file" name="upfile" size=40>
    
    <input type="submit" value="Upload File">
    </form>
    
    
    
    You will then be presented with the file that you uploaded, along with what I named it.  Write
    
    it down, there is no way to retrieve this information after that.
    
    
    
    
    
    <HR width=65% align=left>
    <address>xxx00@xxxxx.net</address>
    
    </body>
    </html>
    There is only one constant, one universal, it is the only real truth: causality. Action. Reaction. Cause and effect...There is no escape from it, we are forever slaves to it. Our only hope, our only peace is to understand it, to understand the 'why'. 'Why' is what separates us from them, you from me. 'Why' is the only real social power, without it you are powerless.

    (Merovingian - Matrix Reloaded)

  4. #4
    Senior Member
    Join Date
    Jun 2004
    Posts
    281
    I am able to use both ASP and PHP I can also use C# if needed. So the language is not really a problem. I would like to go with an ASP language but I am just starting to dig into ASP for real now. So any pointers would be greatly appreciated.

    Neb - Thanks for the coding I will play around with it later. However I am looking more towards ASP but I will still play with the PHP.

    - MilitantEidolon
    Yeah thats right........I said It!

    Ultimately everyone will have their own opinion--this is mine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •