leequalls Posted August 5, 2009 Share Posted August 5, 2009 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 More sharing options...
dadamssg Posted August 5, 2009 Share Posted August 5, 2009 you're trying to unlink a file that you haven't uploaded yet Link to comment https://forums.phpfreaks.com/topic/169000-upload-script/#findComment-891671 Share on other sites More sharing options...
dadamssg Posted August 5, 2009 Share Posted August 5, 2009 and am i missing where you defined the $target variable? Link to comment https://forums.phpfreaks.com/topic/169000-upload-script/#findComment-891673 Share on other sites More sharing options...
leequalls Posted August 5, 2009 Author Share Posted August 5, 2009 ok not sure I just copied it from another page I was using it on I tested it then blocked it now that I have unblocked it and am trying to use it again its not working now so I don't know if I removed something by accident Link to comment https://forums.phpfreaks.com/topic/169000-upload-script/#findComment-891762 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.