Jump to content

Uploading files


zero_ZX

Recommended Posts

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

$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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.