Jump to content

Problem - Move_Uploaded_File


Ustag

Recommended Posts

Hi, I have a file uploader made in flash pointing to upload.php to place the file in correct location and add info to the database. My problem is that this do not work:

//Set some variables$name = $_SESSION['name'];$time = mysql_real_escape_string(time());$date = mysql_real_escape_string(date('Y-m-d'));$ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);$filename = $_FILES['Filedata']['name'];// Move uploaded fileif( $_FILES['Filedata']['error'] == 0 ){    if(move_uploaded_file($_FILES['Filedata']['tmp_name'], "files/".$name."/".$_FILES['Filedata']['name']))    {        echo 'ok';                // Insert data into database        $sql="INSERT INTO `files` (`filename`,`key`,`time`,`date`,`loc`,`ip`,`user`)        VALUES        ('$filename','$key','$time','$date','$name','$ip','$name')";        $result=mysql_query($sql);                exit();    }}

The $name variable do not work and my file is uploaded in just the files folder and the insert into the database get blank where $name should be. But if I do "echo $name;" I will get the right result. Anybody know what might be wrong?I hoe I gave all info that you need to help me solve this. Thank you!

Link to comment
Share on other sites

is it really flash that controlls whats in the if statement? $time$date$ip$filename all those works outside and inside the if, only the $name dont... if I put the session in $name, should that not be exactly the same as the other variables?

Link to comment
Share on other sites

Just to be clear, it's not the case that the variable exists outside of an if statement but not inside. Those are the same scope. PHP doesn't work that way where variables that are defined outside of a structure like an if statement are not defined inside of it (all other things being equal).

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...