Search code examples
phpmysqluploadify

uploadify and sql query


i am using uploadify script to upload files as my school project.

//die($_SESSION['ID'].'.....'.$_SESSION['level']);

if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
    $filename = substr(md5(time()), 0, 8)."-".$_FILES['Filedata']['name'];
    $targetFile =  str_replace('//','/',$targetPath) . $filename;
    $time = time();
    $ID = $_SESSION['ID'];

    $sql = mysql_query("INSERT INTO files VALUES(NULL, '$ID', '$targetFile', '$time')");

    move_uploaded_file($tempFile,$targetFile);
    echo "1";
}

On top $_SESSION['id'] is working, however when i entered inside $sql, it return as 0. Any idea why? i have rechecked everything.

Confused.

Thank you


Solution

  • It seems SESSION doesn't work well with uploadify, i solved it with scriptData uploadify.

    Thank you for all answers.