I Need Help With This Code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    I Need Help With This Code

    I added the following code to my index.php file but for sum reason the code is not working. can anyone help or tell me what to change?

    Code:
    //upload
    else if($action=="upload")
        {
        echo webhead($uthm,$stitle);
        echo "<p align=\"center\">";
        
        if ($upload="upload"&&$superdat_name)
            {
            
            if (!eregi("\.(png)$",$superdat_name))
                {
                echo "[b]Unsuported File extention!!![/b]";
                }
            
            else
                {
                $superdat_name = preg_replace(&#39;/[^a-zA-Z0-9\.\$\%\&#39;\`\-\@\{\}\~\!\#\(\)\&\_\^]/&#39;,&#39;&#39;,str_replace(array(&#39; &#39;,&#39;%20&#39;),array(&#39;_&#39;,&#39;_&#39;),$superdat_name));
    
                if(strlen($superdat_name)>53)
                    {
                    echo "[b]File Name to long!!![/b]";
                    }
                
                else
                    {
                    
                    if (empty($superdat))
                        {
                        echo "[b]No input file specified!!![/b]";
                        }
                    
                    else
                        {
                        copy("$superdat", "upload/$superdat_name")
                        
                        or die("Couldn&#39;t copy file.");
                        }
                    echo "[b]$superdat_name[/b] has been successfully uploaded";
                    }
                }
            }
        
        else
            {
            echo "<form action=\"index.php?action=upload&amp;ses=$ses\" method=\"POST\" ENCTYPE=\"multipart/form-data\">";
            echo "[b]File to be sent :[/b]
    ";
            echo "<input type=\"file\" name=\"superdat\"/>";
            echo "<input type=\"hidden\" name=\"upload\" value=\"upload\"/>
    ";
            echo "<input type=\"submit\" name=\"submit\" value=\"Upload File\"/>";
            echo "</form>";
            echo "
    
    <a href=\"index.php?action=ugal&amp;ses=$ses\">$gallery_simg Gallery</a>
    ";
            echo "<a href=\"index.php?action=main&amp;ses=$ses\">$home_simg Home</a>";
            echo "</p>";
            echo webfoot();
            }
        }

    #2
    Code:
            echo "<form action=\"index.php?action=upload&amp;ses=$ses\" method=\"POST\" ENCTYPE=\"multipart/form-data\">";
            echo "[b]File to be sent :[/b]
    ";
            echo "<input type=\"file\" name=\"superdat\"/>";
            echo "<input type=\"hidden\" name=\"upload\" value=\"upload\"/>
    ";
            echo "<input type=\"submit\" name=\"submit\" value=\"Upload File\"/>";
            echo "</form>";
    when i take these \" out where it says
    Code:
     echo "<input type=\"submit\" name=\"submit\" value=\"Upload File\"/>";
    so it looks like this
    Code:
    echo "<input type=submit name=\"submit\" value=\"Upload File\"/>";
    i run the script in opera, and it says XML parsing failed: syntax error (Line: 1, Character: 124,

    Reparse document as HTML.

    when i click on Reparse document as HTML i can upload files normally, why is this????? what is wrong in the script????

    Comment


      #3
      Code:
              echo "<form action=\"index.php?action=upload&amp;ses=$ses\" method=\"POST\" ENCTYPE=\"multipart/form-data\">";
              echo "[b]File to be sent :[/b]
      ";
              echo "<input type=\"file\" name=\"superdat\"/>";
              echo "<input type=\"hidden\" name=\"upload\" value=\"upload\"/>
      ";
              echo "<input type=\"submit\" name=\"submit\" value=\"Upload File\"/>";
              echo "</form>";
      when i take these \" out where it says
      Code:
       echo "<input type=\"submit\" name=\"submit\" value=\"Upload File\"/>";
      so it looks like this
      Code:
      echo "<input type=submit name=\"submit\" value=\"Upload File\"/>";
      i run the script in opera, and it says XML parsing failed: syntax error (Line: 1, Character: 124,

      Reparse document as HTML.

      when i click on Reparse document as HTML i can upload files normally, why is this????? what is wrong in the script????[/b]

      thats cause it changes the xhtml to html and html wont output that error.

      both ways how u did the submit button are wrong. do this instead
      Code:
      echo "<input type=\"submit\" value=\"Upload File\"/>";
      there shouldnt be any name attribute in submit

      Comment


        #4
        thats cause it changes the xhtml to html and html wont output that error.

        both ways how u did the submit button are wrong. do this instead
        Code:
        echo "<input type=\"submit\" value=\"Upload File\"/>";
        there shouldnt be any name attribute in submit[/b]
        i know, i have managed to fix the prob, i can now upload in xhtml rather than normal html. i have also created a download script to go with this uploader

        Comment

        Working...
        X