$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";
 echo "<br />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 ).

Is there any differece in uploading files in windows server
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!

9 Years
Discussion Span
Last Post by danishbacker

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.


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?


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.


Erghhh.... i getting this problem too.
I hope some body can help this problem :)



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() ;)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.