soycharliente Posted May 28, 2010 Share Posted May 28, 2010 Files are being uploaded to my root directory instead of the specified folder in my code. I've tried multiple options for the upload-to folder that include: $upload_dir = './videos/'; $upload_dir = '/videos/'; $upload_dir = 'videos/'; $upload_dir = $_SERVER['DOCUMENT_ROOT'].'/videos/'; if (count($err) < 1 && $_FILES['File']['error'] == 0) { $v_URL = uploadVideo($_SESSION['UserID'],$id,$issue,$reply,$title,$desc); $upload_dir = './videos/'; $upload_file = basename($upload_dir.$v_URL.'.'.$extension[1]); if (move_uploaded_file($_FILES['File']['tmp_name'], $upload_file)) { //chmod($upload_file, 0705); this doesn't work either, but that's another post soon header('Location: /video.php?id='.$v_URL); exit(); } else { $err['Posting'] = '<p class="error">Could not post video. Please try again.</p>'; } } Can anyone help me? I don't know what questions to ask. Thanks. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 28, 2010 Share Posted May 28, 2010 basename (PHP 4, PHP 5) basename — Returns filename component of path Description string basename ( string $path [, string $suffix ] ) Given a string containing a path to a file, this function will return the base name of the file. ^^^ Why are you using basename() after you have formed your upload path? ^^^ Quote Link to comment Share on other sites More sharing options...
soycharliente Posted May 28, 2010 Author Share Posted May 28, 2010 Good question. When I read the manual about it I just figured it made the slashes go the right way. It was in the tutorial I followed. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted May 28, 2010 Author Share Posted May 28, 2010 I took out the basename() call and reinserted my $_SERVER solution. Works as expected now. chmod() works as expected too, so that fix killed two birds with one stone. if (count($err) < 1 && $_FILES['File']['error'] == 0) { $v_URL = uploadVideo($_SESSION['UserID'],$id,$issue,$reply,$title,$desc); $upload_dir = $_SERVER['DOCUMENT_ROOT'].'/videos/'; $upload_file = $upload_dir.$v_URL.'.'.$extension[1]; if (move_uploaded_file($_FILES['File']['tmp_name'], $upload_file)) { chmod($upload_file, 0705); header('Location: /video.php?id='.$v_URL); exit(); } else { $err['Posting'] = '<p class="error">Could not post video. Please try again.</p>'; } } Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.