by karnetics » Wed Aug 31, 2005 7:46 am
Your error is with your path.. If you have the script files inside the image folder then your path would be
$uploaddir = ' . '; //meaning current folder.
If you move your form & script file outsite the upload directory.. The path should be $uploaddir = 'upload/'; //meaning copy into the folder uploads...
And say if you created a folder called includes.. and move your form & script file into the folder include.
Then you would have to name your path $uploaddir = '/uploads/';
Also note if you use one of the following methods.. If you would like to view the image the same method applys...
example
if my image is set the the path $uploaddir. Depending on where your result script is located you will have to set the path the same or add a slash before the path..
Viewimage.php is located under my root.
The source of my image would be <img src='upload/imagename'>
Here is what I did...
my folder and file structure
/www/
|
|
--->(folder) myimages
| ---->(form) upload.php
|-----(script file) process_upload.php
|
----> (folder) uploads/
------------------------------------------------------------------
# <body>
# <?php
# // In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
# // of $_FILES.
#
# $uploaddir = 'uploads/'; //since my script is out side the upload folder. The path should be this $uploaddir = 'uploads/'.
# $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
#
# echo '<pre>';
# if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
# echo "File is valid, and was successfully uploaded.\n";
# } else {
# echo "Possible file upload attack!\n";
# }
#
# echo 'Here is some more debugging info:';
# print_r($_FILES);
#
# print "</pre>";
#
# ?>