
April 3rd, 2007
11:16 PM
Neverside Newbie
Status: Offline!
File Uploading
So, I basically got this from spoono:
<html>
<head>
<title>TheMungo.com File Uploader</title>
</head>
<body>
<form action="index.php" method="post" ENCTYPE="multipart/form-data">
File to Upload: <input type="file" size="60" name="theFile">
<input type="hidden" name="MAX_FILE_SIZE" value="500000">
<input type="submit" value="upload">
</form>
</body>
</html>
<?
copy($theFile,"/home/themungo/public_html/up/theFile_name");
unlink($theFile);
?>
Except I can't get it to work! Anyone shed some light?
Located at http://themungo.com/up/

April 4th, 2007
01:33 AM
Poseidon
Status: Offline!
Try this. Also, make sure your directory path is correct.
<html>
<head>
<title>TheMungo.com File Uploader</title>
</head>
<body>
<form action="index.php" method="post" ENCTYPE="multipart/form-data">
File to Upload: <input type="file" size="60" name="theFile">
<input type="hidden" name="MAX_FILE_SIZE" value="500000">
<input type="submit" value="upload">
</form>
</body>
</html>
<?php
$theFile = $_FILES['theFile'];
copy($theFile,"/home/themungo/public_html/up/theFile_name");
unlink($theFile);
?>

April 4th, 2007
01:49 AM
Neverside Newbie
Status: Offline!
Nah, that gives me:
Warning: unlink() expects parameter 1 to be string, array given in /home/themungo/public_html/up/index.php on line 20
Im pretty sure its the correct directory path - how can i double check? I've got a phpinfo file at http://themungo.com/phpinfo.php if that helps...

April 4th, 2007
12:07 PM
funny and cheeky
Status: Offline!
$uploaddir="users/"
thats a subdirectory within the same directory as your script.
if(is_uploaded_file($_FILES['thefile']['tmp_name'])){
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['thefile']['name']);
}
I use this and it works for me.
Last edited by schoi, April 4th, 2007 12:09 PM (Edited 1 times)

April 5th, 2007
02:19 PM
I hate Customer Services!
Status: Offline!
I think you will also need to chmod the directory using an ftp program to 777? i might just be talking out of my bum though!
Another good place to check would also be http://www.w3schools.com/php/php_file_upload.asp
I have used that one in the past and know it works!
___________________
PHP Freak Wannabe!
Last edited by tcbil, April 5th, 2007 02:20 PM (Edited 1 times)