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.. Link to comment https://forums.phpfreaks.com/topic/229562-strict-standards-only-variables-should-be-passed-by-reference-in/ 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? Link to comment https://forums.phpfreaks.com/topic/229562-strict-standards-only-variables-should-be-passed-by-reference-in/#findComment-1182728 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 ...... Link to comment https://forums.phpfreaks.com/topic/229562-strict-standards-only-variables-should-be-passed-by-reference-in/#findComment-1182734 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) Link to comment https://forums.phpfreaks.com/topic/229562-strict-standards-only-variables-should-be-passed-by-reference-in/#findComment-1182736 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. Link to comment https://forums.phpfreaks.com/topic/229562-strict-standards-only-variables-should-be-passed-by-reference-in/#findComment-1182743 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)); Link to comment https://forums.phpfreaks.com/topic/229562-strict-standards-only-variables-should-be-passed-by-reference-in/#findComment-1182750 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)); Link to comment https://forums.phpfreaks.com/topic/229562-strict-standards-only-variables-should-be-passed-by-reference-in/#findComment-1182755 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))); Link to comment https://forums.phpfreaks.com/topic/229562-strict-standards-only-variables-should-be-passed-by-reference-in/#findComment-1182759 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 Link to comment https://forums.phpfreaks.com/topic/229562-strict-standards-only-variables-should-be-passed-by-reference-in/#findComment-1182763 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..... ) Link to comment https://forums.phpfreaks.com/topic/229562-strict-standards-only-variables-should-be-passed-by-reference-in/#findComment-1182766 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. Link to comment https://forums.phpfreaks.com/topic/229562-strict-standards-only-variables-should-be-passed-by-reference-in/#findComment-1182769 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.