zero_ZX Posted July 23, 2010 Share Posted July 23, 2010 Hi, I'm having troubles with my variable i guess :/ This is some of my code: <?PHP $brugernavn = mysql_real_escape_string($_POST['brugernavn']); $checkbruger = mysql_query("SELECT brugernavn FROM kunder WHERE brugernavn=('$brugernavn')"); //$user_exists=mysql_query("SELECT username FROM table WHERE username='$username'"); if(mysql_num_rows($checkbruger)>0) { // Config $allowed_filetypes = array('.jpg','.gif','.bmp','.png','.doc','.docx','.xls','.xlsx','.pdf'); $result = mysql_query("SELECT * FROM indstillinger LIMIT 1"); $row = mysql_fetch_array($result); $max_filesize = $row["uploadsize"]; $upload_path = "../kundedata/' . $brugernavn . '/"; $filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension). $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename. I think my problem is the $brugernavn variable in the upload path, but if i'm not able to write it like that, how else would i do it? Link to comment https://forums.phpfreaks.com/topic/208661-uploading-files/ Share on other sites More sharing options...
Zane Posted July 23, 2010 Share Posted July 23, 2010 I think my problem is the $brugernavn variable in the upload path What makes you think that? You have only thrown us a bunch of code and said, something is wrong... elaborate a little. Link to comment https://forums.phpfreaks.com/topic/208661-uploading-files/#findComment-1090112 Share on other sites More sharing options...
RaythMistwalker Posted July 23, 2010 Share Posted July 23, 2010 $checkbruger = mysql_query("SELECT brugernavn FROM kunder WHERE brugernavn=('$brugernavn')"); why is $brugernavn in brackets? it could simply be: $checkbruger = mysql_query("SELECT brugernavn FROM kunder WHERE brugernavn='$brugernavn'"); although that query seems to simply loop round on itself and find the variable you have already got. Link to comment https://forums.phpfreaks.com/topic/208661-uploading-files/#findComment-1090116 Share on other sites More sharing options...
zero_ZX Posted July 23, 2010 Author Share Posted July 23, 2010 When i try to upload a test file it says i need to chmod the folder. This is being tested on windows, and the folder already exists. Error didn't appear when i had $upload_path = "../kundedata/"; The query is there to check if the user exists And i dunno why it's in brackets :/ It works for me like that lol.. Link to comment https://forums.phpfreaks.com/topic/208661-uploading-files/#findComment-1090118 Share on other sites More sharing options...
zero_ZX Posted July 23, 2010 Author Share Posted July 23, 2010 Gentle bump Link to comment https://forums.phpfreaks.com/topic/208661-uploading-files/#findComment-1090319 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.