Hi all,
By the way,yes i've read other threads in the forum related to this and couldn't get the answer. I'm running apache,php 4.3.2 and mysql on windows xp and for some reasons uploads just won't work. My file sharing status on the pc is general sharing.Sometimes the script will upload files but only if they're within the directory that i keep my php files or any directories within that. It won't upload from any directory in the pc. I'm confused. Any ideas??? By the way I've tried many variations with the destination path of the upload and it still won't work. All i wanna do is upload an audio file, open read and insert it into mysql. I can do the open, read,insert bit when the user provides an absolute path to the file, but uploads would be more sophisticated.
here's the main part of the form:
<form enctype="multipart/form-data" action="work.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1M" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
...and here's the script that handles the form
The possible file upload attack is almost always echoed)
$uploaddir = 'shortClips//';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo $uploadfile;
echo "File is valid, and was successfully uploaded. ";
echo "Here's some more debugging info:\n";
echo($_FILES['userfile']['error']);
echo "uploadfile is".$uploadfile;
$file = fopen("$uploadfile","rb") or die( "Can't open file!" );
$audio = mysql_escape_string(fread($file, filesize("$uploadfile")));
echo $audio;
fclose($file);
} else {
echo "\ntemp is".$_FILES['userfile']['tmp_name'];
echo "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
By the way,yes i've read other threads in the forum related to this and couldn't get the answer. I'm running apache,php 4.3.2 and mysql on windows xp and for some reasons uploads just won't work. My file sharing status on the pc is general sharing.Sometimes the script will upload files but only if they're within the directory that i keep my php files or any directories within that. It won't upload from any directory in the pc. I'm confused. Any ideas??? By the way I've tried many variations with the destination path of the upload and it still won't work. All i wanna do is upload an audio file, open read and insert it into mysql. I can do the open, read,insert bit when the user provides an absolute path to the file, but uploads would be more sophisticated.
here's the main part of the form:
<form enctype="multipart/form-data" action="work.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1M" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
...and here's the script that handles the form
$uploaddir = 'shortClips//';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo $uploadfile;
echo "File is valid, and was successfully uploaded. ";
echo "Here's some more debugging info:\n";
echo($_FILES['userfile']['error']);
echo "uploadfile is".$uploadfile;
$file = fopen("$uploadfile","rb") or die( "Can't open file!" );
$audio = mysql_escape_string(fread($file, filesize("$uploadfile")));
echo $audio;
fclose($file);
} else {
echo "\ntemp is".$_FILES['userfile']['tmp_name'];
echo "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}