Jump to content

Whats wrong with this script


.-INSANE-.

Recommended Posts

ok i go to preview it on the dreamweaver thing and some of this script shows up i cant figure out whats wrong

[code]
<?PHP
if($_POST['submit']){
$directory = "/home/username/public_html/files/";
$max_file_size = "26214400";
$allowedfile[] = "video/x-ms-wmv";  
$allowedfile[] = "video/x-msvideo";  
$allowedfile[] = "video/mpeg";  
$allowedfile[] = "video/quicktime";  
if (is_uploaded_file($_FILES["file"]["tmp_name"])) {    
    if($_FILES["file"]["size"]>$max_file_size) {        
        $is_uploaded = "failed";      
        echo 'Sorry, this file is too large. The maximum filesize is '.$max_file_size.' bytes, although your file is '.$_FILES["file"]["size"].'. ';        
        exit();    
        }    
        if(!in_array($_FILES["file"]["type"],$allowedfile)) {        
            $is_uploaded = "failed";        
            echo 'Sorry, wrong file type, "'.$_FILES["file"]["type"].'" is not allowed. ';      
            exit();  
        }    
        if(file_exists($directory.$_FILES["file"]["name"])) {        
            $is_uploaded = "failed";        
            echo 'Sorry, this file already exists. ';        
            exit();
        if($is_uploaded!="failed") {
               $replace = array("$","%","#","@","!","&","^","*","(",")","-");
            $new = str_replace($replace,"",$_FILES["file"]["name"]);
            $fileName = str_replace(" " , "_" , $new);

        if(! is_dir($directory)){
                mkdir($directory,0777);
            }
        if (move_uploaded_file($_FILES["file"]["tmp_name"], $directory.$fileName)) {
                echo "Your file, ". $fileName ." has successfully been uploaded!  Click <a href=\"".$directory.$fileName."\">Here</a> to view your file.";
            }
    else {
        echo 'Sorry, your file has not uploaded.';
        exit();
        }
    }
} else {
    echo 'There has been an unknown error while uploading';
    exit();
}
}
?>[/code]
Link to comment
Share on other sites

if you do not preview it throught a web browser by typeing [a href=\"http://127.0.0.1\" target=\"_blank\"]http://127.0.0.1[/a] or your ip address or webpage name you will see the code because php only parses it through a web browser
Link to comment
Share on other sites

Actually it has nothing to do with the browser, but PHP is only processed with an interpreter. Dreamweaver does not have an interpreter. You can configure your local system to execute php scripts via the php interpreter or via a httpd, which employs the php interpreter to process the script before passing it to the client that generated the request (generally a web browser).
Link to comment
Share on other sites

ok i got it now i dont understand what to do i go to dreamweaver and it still shows up bad and i dont understnad whats wrong wit it

i alos cant get apache to start only thing running is mysql is that the problem

ok i now uninstalled and then reinstalled and now i have FileZilla running but when i hir start on Apache itll strat for a quick second then itll end
Link to comment
Share on other sites

The million dollar question is what is the conflict in your configuration which causes Apache to fail to load. Are there any error messages returned when you try to start Apache?

Dreamweaver will not view PHP files correctly because it does not contain an interpreter and therefore can not comprehend it or the desired end results of it. I don't think I can make it any clearer, at the moment. If anyone feels the need to elaborate, please do so.

Edit: Dreamweaver was only designed to edit (x)html/javascript/dhtml/etc...things that a web browser processes as this deals with the end result. It was not designed to handle things that are processed on the server-side.
Link to comment
Share on other sites

Though that would be a wonderful tool for those that do not understand (x)html, but would like to make minor changes to their premade scripts, I have no knowledge of such a thing. My suggestion to you is to spend a little time studying xhtml, php and css. Then, if you insist on using a WYSIWYG editor, you will be able to design the page in the editor and go to code view and insert php snippets. It won't look right in the editor, but then you can view it on the server.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.