Internal Server Error

Status
Not open for further replies.

yondaime.tori88

New Member
Messages
7
Reaction score
0
Points
0
I have created an php file to upload .zip or .rar files,at the beginning it says that mkdir() function couldn't access to the folder(public_html/sgfoldup)(permission denied).
So i have changed the permission on these folders(each on 777) and appears this error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, no-reply@x10hosting.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

How can i solve it?
Thanks
 

Gouri

Community Paragon
Community Support
Messages
4,565
Reaction score
245
Points
63
I have created an php file to upload .zip or .rar files,at the beginning it says that mkdir() function couldn't access to the folder(public_html/sgfoldup)(permission denied).
So i have changed the permission on these folders(each on 777) and appears this error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, no-reply@x10hosting.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

How can i solve it?
Thanks

777 permission is not secure

Change the permissions to 755 for folders and 644 for files.
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Also, if this script is for people to upload and store files, please note two things:

1. You are 100% responsible for what is on you account. One piece of warez, adult material, or anything else that violates x10hosting's TOS will get your account locked and deleted. No backups or downloads.

2. If the purpose of the site is a file warehouse, that violates the TOS too.
 

yondaime.tori88

New Member
Messages
7
Reaction score
0
Points
0
This is my upload.php code:
PHP:
<?php

include 'dbc.php';


$dimensione_massima=10240; //dimensione massima consentita per file in byte -> 1024 byte = 1 Kb
$dimensione_massima_Kb=$dimensione_massima/1024;

// percorso cartella relativo $cartella_upload="../public/";
$filtrare=1; //filtrare x estensioni ammesse? 1=si 0=no
$array_estensioni_ammesse=array('.zip','.rar'); //estensioni ammesse

$savgn = $data['savename'];
$region = $data['region'];
$description = $data['description'];
$username = $data['username'];
$dlc = $data['dlc'];
$trof=$data['trof'];
$trofei = $data['trofei'];
$cartella_upload="/public_ftp/sgfoldup/".$username;//cartella in cui eseguire l'upload (controllare permessi scrittura)
$file_path="/public_ftp/sgfoldup/".$username."/".$data['upfile']; 
$errorecomp=0; 

if(is_dir($cartella_upload)==false)
 Mkdir($cartella_upload, 0755,true);

if($savgn=='' || $description=='' || $username==''  || is_int($trofei)==false || $savgn>=255 || $region>=20 || $description>=255 || $username>=16 || $trofei>=100){
   echo('Check Field');
   $errorecomp+=1; 
   }
else if($errorecomp==0 ){
if(!isset($_FILES['upfile']) || $_FILES['upfile']['size']==0){
    echo "No file selected";
}else if($_FILES['upfile']['size']>$dimensione_massima){
    echo "The file is too large $dimensione_massima_Kb Kb";
}else{
    $nome_file=$_FILES['upfile']['name'];
    $errore="";
    if($filtrare==1){
        $estensione = strtolower(substr($nome_file, strrpos($nome_file, "."), strlen($nome_file)-strrpos($nome_file, ".")));
        if(!in_array($estensione,$array_estensioni_ammesse)){
            $errore.="File not accepted. Permitted extensions: ".implode(", ",$array_estensioni_ammesse)."<br/>";
        }
    }
    if(!file_exists($cartella_upload)){
        $errore.="The folder doesn't exist</br>";
    }
    
    if($errore==""){
        if(move_uploaded_file($_FILES['upfile']['tmp_name'], $cartella_upload.$_FILES['upfile']['name'])){
            chmod($cartella_upload.$_FILES['upfile']['name'],0644); //permessi per poterci sovrascrivere/scaricare
            echo "Upload successful.";
            //aggiunta al database
            if($trof=='si'){
            $sql_insert = "INSERT into `savegame`
              (`savename`,`username`,`description`,`region`,`pathsave`,`dlc`,`trof`,`trofei`,`date`,`users_ip`)
            VALUES
            ('$savgn','$username','$description','$region','$file_path','$dlc','$trof','$trofei',now(),'$user_ip')";}
            else if($trof=='no'){
            $sql_insert = "INSERT into `savegame`
              (`savename`,`username`,`description`,`region`,`pathsave`,`dlc`,`trof`,`date`,`users_ip`)
            VALUES
            ('$savgn','$username','$description','$region','$file_path','$dlc','$trof',now(),'$user_ip')";
             header('Location: http://farebury.exofire.net/Upload.html');
            }
            }
        }else{
            echo "Unable to upload file";
        }
    }
    if($errore!=''){
        echo $errore;
    }
}

?>
public_html:700
public_ftp:755
this is the error:
Code:
[B]Warning[/B]:  mkdir() [[URL="http://farebury.exofire.net/function.mkdir"]function.mkdir[/URL]]: Permission denied in [B]/home/oxoc/public_html/upload.php[/B] on line [B]25[/B]
How can i solve it?
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
PHP:
Mkdir($cartella_upload, 0755,true)

is what is causing the error.

Exactly what is the full name and path of the dir you are trying to create?
 

yondaime.tori88

New Member
Messages
7
Reaction score
0
Points
0

"/public_ftp/sgfoldup/"
.$username


To organize the upload i want to create a folder with the same name of the uploader($username)
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Please notice the path to your script in the error message...

Code:
/home/oxoc/public_html/upload.php
 
Status
Not open for further replies.
Top