Reply to Re: file upload problem

Your name:

Reply:


Posted by Johnny on 10/12/06 13:35

I guess instead of complaing about it I should of joined the thread back
together like I'm doing now :-( see below for the next installment, hmm I
wonder if this really will stitch the thread back together...like where will
it end up in alt.php...we'll see

On Oct 12, 10:01 am, "ljuljacka" <ljulja...@yahoo.com> wrote:
> I'm just trying to run a fileupload script from the manual, just to see
how
> it works, and it won't. I've checked if file upload is enabled and it is.
> Also, the file I'm trying to upload is smaller then max. The folder I'm
> trying to upload files to is ./ispit1. I always get the "wrong" echo from
> the script when I run debug in my editor and when I run it in my browser
> (firefox) I get the following message:
> "The requested URL /ispit/__URL__ was not found on this server."
> The file isn't transfered to tmp directory either.
> Any help is welcome.
>
> <form enctype="multipart/form-data" action="__URL__" method="POST">
> <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
> Send this file: <input name="userfile" type="file" />
> <input type="submit" value="Send File" />
> </form>
>
> <?php
> $uploaddir = './ispit1/';
> $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
>
> 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";}?>

"FlungaBunga" <IanJamesGrant@gmail.com> wrote in message
news:1160614668.777264.106700@h48g2000cwc.googlegroups.com...
Hey,

Probably just look at the basics first.

you've selected the destination folder to be './ispit1', which is a
relative file path. I would recommend that you provide the script with
an absolute path to the destination so that regardless where you
execute your script from you'll be moving the files into the correct
folder. That'll make debugging the script much easier as you won't be
searching the file system for ispit1 folders ;)

Let us know how you go :)

"Johnny" <removethis.huuanito@hotmail.com> wrote in message

Every LAMP server I've worked on doesn't have write file permission to do
the move. PHP always seems to run as 'other' and to allow wriet permssions
on 'other' would not seem to be a good thing. The way I have been able to
do it is by incorporating PHP FTP functions and moving the file with them.

Here's how I debug by putting this at the top of the file posted to right
after the opening php tag:
var_dump($_FILES);
and see what's happening.
Most likely its permissions though
--------------------------
OK next installment:
2 problems:
> "The requested URL /ispit/__URL__ was not found on this server."
you don't know where your directory is (FlungaBunga advice above is good
place to start)

> The file isn't transfered to tmp directory either
and the upload doesn't seem to arrive

So to debug the first problem do this:

echo "<br />cwd=".getcwd(); # show where you are, this'll help u figure
where ./ispit1/ goes to
if ($handle = opendir($uploaddir)) { # in php5 use scandir to replace this
block
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
echo "$file<br />";
}
} else {
echo "<br />could not open that directory<br />";
}

for the second problem use var_dump($_FILES); on entry to your script to
see where stuff goes.

with those tools and FlungaBunga's advice you should have this solved in
short order. Good luck :-)

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация