Titan85
01-13-2007, 03:46 PM
I created a little script to upload files, but I keep getting an error while uploading. Here is my code:
<?php
if($_POST['upload']) {
$path = $_POST['path'];
$upload_path = $path . basename($_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $path)) {
echo 'The file: '.$_FILES['file']['name'].' has been uploaded. <br /> Details:';
echo 'File Type '.$_FILES['file']['type'].' <br />
File Size: '.$_FILES['file']['size'].' <br />
File Name: '.$_FILES['file']['name'].'';
}
else {
echo 'There was an error while uploading the file!';
}
}
?>
<form method="post" action="" enctype="multipart/form-data">
<b>File To Upload</b>:
<br />
<input type="file" name="file" />
<br /><br />
<b>Directory To Upload To</b>:
<br />
<input type="text" name="path" value="/directory" />
<br /><br />
<input type="submit" name="upload" value="Upload" />
</form>I chmodded the directory I am uploading to to 777 and all, but I still get the error: "
Warning: move_uploaded_file(uploads/): failed to open stream: Is a directory in /home/bntqann/public_html/testing/file_upload/upload.php on line 8
Warning: move_uploaded_file(): Unable to move '/tmp/phpCNrQ1u' to 'uploads/' in /home/bntqann/public_html/testing/file_upload/upload.php on line 8
There was an error while uploading the file!". I am at a loss as to why it is giving the error, I appreciate any help :)
<?php
if($_POST['upload']) {
$path = $_POST['path'];
$upload_path = $path . basename($_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $path)) {
echo 'The file: '.$_FILES['file']['name'].' has been uploaded. <br /> Details:';
echo 'File Type '.$_FILES['file']['type'].' <br />
File Size: '.$_FILES['file']['size'].' <br />
File Name: '.$_FILES['file']['name'].'';
}
else {
echo 'There was an error while uploading the file!';
}
}
?>
<form method="post" action="" enctype="multipart/form-data">
<b>File To Upload</b>:
<br />
<input type="file" name="file" />
<br /><br />
<b>Directory To Upload To</b>:
<br />
<input type="text" name="path" value="/directory" />
<br /><br />
<input type="submit" name="upload" value="Upload" />
</form>I chmodded the directory I am uploading to to 777 and all, but I still get the error: "
Warning: move_uploaded_file(uploads/): failed to open stream: Is a directory in /home/bntqann/public_html/testing/file_upload/upload.php on line 8
Warning: move_uploaded_file(): Unable to move '/tmp/phpCNrQ1u' to 'uploads/' in /home/bntqann/public_html/testing/file_upload/upload.php on line 8
There was an error while uploading the file!". I am at a loss as to why it is giving the error, I appreciate any help :)