1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Rep Power

    File Upload and Calling Cgi files

    I appreciate your help in cracking the following issue

    Functionality - A File will be uploaded from a webpage and On Form Submit The Following Cgi_script is being Called.

    The Script in turn checks for the availability of the File and does 2 conversion based on Format (6/7)
    (1) from utf16 - utf8
    (2) Replaces Tabs with Comma
    and generates the output in a File

    PROBLEM Description
    - Why does the File never gets Uploaded Only when i am adding the Conditions for File Manipulation. Otherwise the File script Works like a Charm

    - There is a Cronjob Running few minutes to set the File Permissions on the File whichever is being loaded
    But Doesnt show up anything when i do ls -al <File NAme> and i get a 500 error

    - Am i missing something Here

    Code goes as below

    use lib '/u02/Upld';
    # End of Configurable Options.

    use CGI qw(:standard);
    $query = new CGI;
    chop $SAVE_DIRECTORY if ($SAVE_DIRECTORY =~ /\/$/);

    if ($query->param("file_01") =~ /([^\/\\]+)$/) {
    $Filename = $1;
    $File_Handle = $query->param("file_01");
    $BytesRead = 0;
    $Buffer = "";
    $output67 = $SAVE_DIRECTORY . "/utf_" . $Filename;
    $infile = "$SAVE_DIRECTORY\/$Filename";

    if ($format == 6 || $format == 7) {
    system "touch $output67";

    while (1==1){
    ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,$atime, $mtime, $ctime, $blksize, $blocks)= stat($infile);
    $FAccs = -X $infile;
    if ($mode == 33279 && $FAccs == 1){ last; }
    $line = <FILE>;
    @check = unpack("CCC",$line);
    print join(',',@check),"\n";

    if ($check[0]=255 && $check[1]=254 ){
    $Charset = "utf8";
    system "iconv -f UTF-16 -t UTF-8 $infile > $output67";
    system "perl -pi -e $Convrsn $output67";
    $outputf = $output67;

    $outputf = $infile;

    print "Content-type: text/html;\n\n";
    print <<__END_OF_HTML_CODE__;
    <head><script LANGUAGE="javascript">
    function SubmitForm() {
    document.Up.submit(); }
    <title>TESTING Upload</title>
    <body bgcolor="#FFFFFF" vlink="#0000FF" alink="#0000FF" topmargin="5" leftmargin="15" onLoad="SubmitForm();">
    <table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>
    <td valign="top" align="left" width="100%" bgcolor="#FFFFFF">
    <strong><font size="2" face="Arial,Helvetica">
    The following files were sucessfully uploaded <br><br>

    print "<INPUT TYPE=\"hidden\" NAME=\"p_Id\" VALUE=\"$process_id\">\n";
    print "<INPUT TYPE=\"hidden\" NAME=\"p_Filename\" VALUE=\"$Filename\">\n";
    print "<INPUT TYPE=\"hidden\" NAME=\"p_DataSource\" VALUE=\"$p_data_source\">\n";
    print "<INPUT TYPE=\"hidden\" NAME=\"p_CharSet\" VALUE=\"$Charset\">\n";
    print "<INPUT TYPE=\"hidden\" NAME=\"p_Format\" VALUE=\"$format\">\n";
    print "<INPUT TYPE=\"hidden\" NAME=\"p_Id2\" VALUE=\"$process_id1\">\n";

    print "&nbsp;&nbsp;&nbsp;$Filename - <br>\n";
    print <<__END_OF_HTML_CODE__;
    <br>Please wait a moment while the database is updated...<br><br>
    <INPUT TYPE="Submit" NAME="Button" Value=" Cancel ">
    Last edited by chev; July 24th, 2003 at 08:15 PM.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Rep Power

    File Upload

    I got how File Upload Works in Cgi and here is the url for anybody who is looking for an answer


IMN logo majestic logo threadwatch logo seochat tools logo