Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

uploads won't happen

Status
Not open for further replies.

molly2ka

Programmer
Mar 20, 2004
27
US
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);
}
 
Is that second forward slash in your $uploaddir variable a typo? I don't think the filesystem would like that...
 
AND u should use $uploaddir = './shortClips/';

i had some problem with that lil var in my server, without ./ wouldn't work ;)

and like sleipnir214 said u have to chmod the directory appropriately (i always use 777 for the temp dir, as whatever file goes there during processing gets deleted so no problem there)

jamesp0tter,
jamespotter@netcabo.pt

p.s.: sorry for my (sometimes) bad english :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top