<?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 "<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 ).
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!

Recommended Answers

All 7 Replies

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.

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.

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?

no warning or error is shown, the program stops there.

Thanks.

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 :)

Thanks

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.