Problem with file upload in windows server
<?php
$fileName = basename( $_FILES['fileName']['name']);
//count current total files
$dir_path = "snaps/";
$count = count(glob($dir_path . "*"));
$newFileName = $count . ".jpg";
$target_path = "snaps/" . $newFileName;
if(move_uploaded_file($_FILES['fileName']['tmp_name'], $target_path)) {
echo "<br/>Success";
else{
echo "Failed";
}
?>
The above works in my unix like server
(Linux server.nixism.com 2.6.18-53.1.14.el5 #1 SMP Wed Mar 5 11:37:38 EST 2008 x86_64)
but it is not working in a windows server ( Windows NT P3SWH132 5.2 build 3790 ).
why?
Is there any differece in uploading files in windows server
or
is it the directory stucture given above ( '/ 'or '\\')
also the linux server is having php5.2.6
and the windows server is having php4.3.11 is anything to with this?
Help me. please find the error!
danishbacker
Junior Poster in Training
97 posts since Apr 2008
Reputation Points: 10
Solved Threads: 7
What error are you receiving? Is it apache or IIS (don't know if this matters, but / works on my apache in windows).
Does the snaps directory already exist? Because you might get an error (Permission Denied.) if it doesn't.
Hope this helps.
scru
Posting Virtuoso
1,629 posts since Feb 2007
Reputation Points: 975
Solved Threads: 140
Thanks for your reply
the directory already exists and the server is IIS6
also my file size is less than 2mb
server api is ISAPI
please check the following link for more details
http://symphonydoha.com/phpinfo.php
Thanks.
danishbacker
Junior Poster in Training
97 posts since Apr 2008
Reputation Points: 10
Solved Threads: 7
1: Posting your phpinfo() on the web is a bad idea.
2. Does PHP give you an error or warning on move_uploaded_file()? What does it say?
scru
Posting Virtuoso
1,629 posts since Feb 2007
Reputation Points: 975
Solved Threads: 140
no warning or error is shown, the program stops there.
Thanks.
danishbacker
Junior Poster in Training
97 posts since Apr 2008
Reputation Points: 10
Solved Threads: 7
I tried to do this in asp, then also same problem, later i found that i have no write permission for that directory. hope giving write permission will solve my problem. But for that i have to contact the administrator.
danishbacker
Junior Poster in Training
97 posts since Apr 2008
Reputation Points: 10
Solved Threads: 7
Erghhh.... i getting this problem too.
I hope some body can help this problem :)
Thanks
cakka
Junior Poster in Training
65 posts since Mar 2007
Reputation Points: 10
Solved Threads: 1
The problem was solved temporarily, thats why I didnt updated the thread.
It was solved by getting write permission to that directory.
For this I mailed the admin of hosting company specifying my needs.
They gave me write permission.
This was the problem, that I was only having read permission.
This could be easily done in a linux based server using CHMOD() ;)
danishbacker
Junior Poster in Training
97 posts since Apr 2008
Reputation Points: 10
Solved Threads: 7