dlc Posted March 4, 2011 Share Posted March 4, 2011 Hello, I have a "working" upload script but i do get an error: Strict Standards: Only variables should be passed by reference in C:\Users\UHN\Desktop\xampp-win32-1.7.4-VC6\xampp\htdocs\upload.php on line 99 Line 99: $file_ext = strtolower(end(explode('.', $file_name))); thanks.. Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted March 4, 2011 Share Posted March 4, 2011 what is $file_name? an array or a flat variable? Quote Link to comment Share on other sites More sharing options...
dlc Posted March 4, 2011 Author Share Posted March 4, 2011 I will put some more code to make ik clearer. if($_SERVER['REQUEST_METHOD'] == "POST") { $input_name = $_POST['filename']; // The given name $file_name = $_FILES['filen']['name']; // The file name of the uploaded file $file_ext = strtolower(end(explode('.', $file_name))); // Get the extension ...... Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted March 4, 2011 Share Posted March 4, 2011 Out of cuiosity, what do you get if you print_r($file_name) Quote Link to comment Share on other sites More sharing options...
dlc Posted March 4, 2011 Author Share Posted March 4, 2011 I uploaded the file: aannp.pdf And print_r($file_name); gives: aannp.pdf so that should be right. Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted March 4, 2011 Share Posted March 4, 2011 yeah, looks like it should be spot on. How about trying this in place of it and see what you get? $file_ext = strtolower(substr($file_name), -(strpos($file_name, '.')+1)); Quote Link to comment Share on other sites More sharing options...
dlc Posted March 4, 2011 Author Share Posted March 4, 2011 I get: Warning: substr() expects at least 2 parameters, 1 given in C:\Users\UHN\Desktop\xampp-win32-1.7.4-VC6\xampp\htdocs\upload.php on line 100 Warning: strtolower() expects exactly 1 parameter, 2 given in C:\Users\UHN\Desktop\xampp-win32-1.7.4-VC6\xampp\htdocs\upload.php on line 100 line 100 is: $file_ext = strtolower(substr($file_name), -(strpos($file_name, '.')+1)); Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted March 4, 2011 Share Posted March 4, 2011 my bad, malformed the code $file_ext = strtolower(substr($file_name, -(strpos($file_name, '.')+1))); Quote Link to comment Share on other sites More sharing options...
dlc Posted March 4, 2011 Author Share Posted March 4, 2011 Now i have a new error: Notice: Undefined variable: extensioncheck in C:\Users\UHN\Desktop\xampp-win32-1.7.4-VC6\xampp\htdocs\upload.php on line 116 $extensioncheck is an array holding multiple extensions including " .pdf " If i use print_r($file_ext); i get: np.pdf The original name is aannp.pdf Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted March 4, 2011 Share Posted March 4, 2011 cahnge +1 to -1 and see how it goes ( I keep getting confused when working backwards through a string...and with most other things in life..... ) Quote Link to comment Share on other sites More sharing options...
dlc Posted March 4, 2011 Author Share Posted March 4, 2011 It works! thank you for your help dlc. 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.