Invalid argument when uploading file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aLieNzDaToR
Forum Newbie
Posts: 4
Joined: Sun Mar 06, 2011 9:08 pm

Invalid argument when uploading file

Post by aLieNzDaToR »

Hi!

I have created a function for users to upload a file into a unix shared server.My system is stored in another windows server. I am using WAMP to run the php server.
My problem is, before this, i have encounter access permission issue when i'm trying to upload a file into the shared server. It keeps give an error about permission denied. After that, i have assigned the php server into a group that have read and write access to the unix shared server. Then, i have no problem to upload and download the file from the unix shared server.

After some times, it does not work anymore. When i tried to upload a file or create directory to that unix shared server, it gives an error like this:
Warning: move_uploaded_file(\\xxx/file.doc) [function.move-uploaded-file]: failed to open stream: Invalid argument in xxxx on line xx
But if i use the same code to upload a file from the php server to my pc (i shared a folder and gives read and write access to the php server), it works perfectly.
I already checked the access permission for the php server and it still in a group that has read and write access to the unix shared server.

Does anybody know how to solve this problem? Any idea about this would help. Thanks a lot.
maxx99
Forum Contributor
Posts: 142
Joined: Mon Nov 21, 2011 3:40 am

Re: Invalid argument when uploading file

Post by maxx99 »

First instead of:

Code: Select all

move_uploaded_file(\\xxx/file.doc) 
try

Code: Select all

move_uploaded_file("\\xxx/file.doc");
aLieNzDaToR
Forum Newbie
Posts: 4
Joined: Sun Mar 06, 2011 9:08 pm

Re: Invalid argument when uploading file

Post by aLieNzDaToR »

Actually, my code is like this;

Code: Select all

$name = $_FILES['file']['name'];
$temp = $_FILES['file']['tmp_name'];
$target_path = "\\\\xxx/folder/";
$target_path = $target_path . basename($name);
move_uploaded_file($temp , $target_path);
Maybe the problem is not from the code since it's worked before. Anyway, thanks for the reply. :)
maxx99
Forum Contributor
Posts: 142
Joined: Mon Nov 21, 2011 3:40 am

Re: Invalid argument when uploading file

Post by maxx99 »

Re-check if destination directory is writable.

Code: Select all

http://php.net/manual/en/function.is-writable.php
Depending on how you access the shared server you can e.g. chmod from shell or set it via FTP.
aLieNzDaToR
Forum Newbie
Posts: 4
Joined: Sun Mar 06, 2011 9:08 pm

Re: Invalid argument when uploading file

Post by aLieNzDaToR »

i wonder why, when i check the destination directory using that function, it said that the directory is not writable even i already assign that web server to a group that has read and write access to it. However, thanks a lot maxx. Really appreaciate it..
aLieNzDaToR
Forum Newbie
Posts: 4
Joined: Sun Mar 06, 2011 9:08 pm

Re: Invalid argument when uploading file

Post by aLieNzDaToR »

Does anybody know, why it still gives an error when i'm uploading a file, even i already gave read and write access to the disk for "Everyone"? When i'm tried to use the writeable function, the return value is false. However, i have no problem to read and write the disk via file browser. Anyone??
Post Reply