I Need Help With This Code

Started on the old forum in June 2008 · view the original in the archive · old links redirect here

3 replies · 469 views · started 18 years ago · 1 min read

2 participants
synergyx Developer · 100 posts #1

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?

//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('/[^a-zA-Z0-9\.\$\%\'\`\-\@\{\}\~\!\#\(\)\&\_\^]/','',str_replace(array(' ','%20'),array('_','_'),$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't copy file.");
                    }
                echo "[b]$superdat_name[/b] has been successfully uploaded";
                }
            }
        }
    
    else
        {
        echo "<form action=\"index.php?action=upload&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&ses=$ses\">$gallery_simg Gallery</a>
";
        echo "<a href=\"index.php?action=main&ses=$ses\">$home_simg Home</a>";
        echo "</p>";
        echo webfoot();
        }
    }
synergyx Developer · 100 posts #2
        echo "<form action=\"index.php?action=upload&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

 echo "<input type=\"submit\" name=\"submit\" value=\"Upload File\"/>";

so it looks like this

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: 1248),

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????

wizard Senior · 493 posts #3
        echo "<form action=\"index.php?action=upload&ses=$ses\" method=\"POST\" ENCTYPE=\"multipart/form-data\">";
        echo "File to be sent :
";
        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

 echo "<input type=\"submit\" name=\"submit\" value=\"Upload File\"/>";

so it looks like this

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: 1248),

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????

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

echo "<input type=\"submit\" value=\"Upload File\"/>";

there shouldnt be any name attribute in submit

synergyx Developer · 100 posts #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

echo "<input type=\"submit\" value=\"Upload File\"/>";

there shouldnt be any name attribute in submit

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

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close