Jump to content

upload script


leequalls

Recommended Posts

I am getting an error with this code and I dont know why it was working:

 

$rs2 = mysql_query("SELECT * FROM upload");
$uploaddir = "/public_html/party934/files/ids";

if ($_POST['form'] == 'upload') {
    $file = basename( $_FILES['file']['name']);
    $pext = getFileExtension($file);
    $pext = strtolower($pext);
    if (($pext != "mp3"))
    {
        print "<h1>ERROR</h1>File Extension Unknown.<br>";
        print "<p>Please upload only Audio files with the extensions .mp3 <br><br>";
        print "The file you uploaded had the following extension: $pext</p>\n";

        unlink($file);
        exit();
    }

    $final_filename = str_replace(" ", "_", $file);
    $newfile = $uploaddir . "/$final_filename";
    
    //== do extra security check to prevent malicious abuse=
    if (is_uploaded_file($file))
    {

       //== move file to proper directory ==
       if (!copy($file,"$newfile")) 
       {
             print "Error Uploading File.";
          exit();
       }
     }

    //== delete the temporary uploaded file ==
    unlink($file);

$genre = $_POST["genre"];
$date = date("Y-m-d");
$sessname = $_SESSION['asess_name'];
$ok=1; 
if(move_uploaded_file($_FILES['file']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['file']['name']). " has been uploaded";
for ($i = 0; $i < $count; $i++) {
$ufile = mysql_result($rs2, $i, 'file');
if ($ufile == $file) { mysql_query("UPDATE upload set (file, date, name, genre) values ('$file','$date','$sessname','$genre') where file='$file'"); $done = 'true'; }
}} else {echo "Sorry, there was a problem uploading your file.";}
if ($done != 'true') { mysql_query("INSERT INTO upload (file, date, name, genre) values ('$file','$date','$sessname','$genre')"); 
}}

 

and here is the error message:

 

Warning: unlink(file name.mp3) [function.unlink]: No such file or directory in /home/leequall/public_html/party934/home.php on line 361

 

Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File() is not within the allowed path(s): (/home/leequall:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/leequall/public_html/party934/home.php on line 367

Link to comment
https://forums.phpfreaks.com/topic/169000-upload-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.