Page 2 of 3

Posted: Wed Jun 18, 2003 9:27 am
by Luis Almeida
Php is running on the PC Number One wich is the one with the server installed on (Sambar Server)

Posted: Wed Jun 18, 2003 9:50 am
by releasedj
This seems to be getting more confusing as the setup seems unclear.

Take PHP out of the equation. Then describe exactly how this transfer should be happening!
Explain which machine has what installed. Where the files for the transfer are, and where they need to go.

Kelvin

Posted: Wed Jun 18, 2003 10:15 am
by Luis Almeida
Ok, let´s try...

1 - I´m currently working on a IntraNet

2 - There are two PC´s

3 - PC number One is the one with the server (Sambar) and PHP
installed on it

4 - PC number two is another PC on the intranet

5 - If I try to upload the file from PC number ONE, it work fine. this is the file goes to the folder "UPLOAD" on the server

6 - If I try to upload the file from PC number TWO, if fails because PHP expect to find it (open it) on PC number one.

It seem's that regardless from no matter what pc I try to upload the file, PHP tries to locate it on the SERVER (PC NUMBER ONE)

for example if I try to upload the file on C:\TEST.TXT on PC number TWO, PHP tries to open it on PC NUMBER ONE to upload it to the server, and if there are no C:\TEST.TXT on PC number ONE the the upload fails but if there is also the file C:\TEST.TXT on PC number ONE then PHP uploads it but offcourse that is the wrong file because I want to upload the file from PC number TWO and not FROM PC number ONE.
I Know that´s confusing ans odd can you please help me???

Posted: Wed Jun 18, 2003 10:32 am
by releasedj
PHP is a server-side technology. It isn't possible for it to read the drive of a client computer.

If it's a simple file upload that you're after then look at the PHP manual on how you can accomplish this. http://uk.php.net/manual/en/features.file-upload.php

Posted: Wed Jun 18, 2003 10:37 am
by Luis Almeida
Are you telling to me that it´s not possible for me to upload a file larger than 100Mb (i.e.) using php ftp functions from a client machine ???

Posted: Wed Jun 18, 2003 11:18 am
by releasedj
Where did you read that? Where have I written anything about file size limits?

Remember that PHP is installed on your SAMBAR server. Which is also the FTP server.
Imagine that you were sitting at that server and you wanted to upload the file on the client machine. How would you do it?

Is the client machine an FTP server? No.
Is there a mapped drive to a share on the client machine? Maybe, but I doubt it.

Remember PHP is running on the server, not the client.

Posted: Mon Jun 23, 2003 4:23 am
by Luis Almeida
I´m getting more confused.....

My problem is that I want to upload a Large File from a client machine.

Is it possible to do this????

If it is, then why is that every time I try to upload a file on the client machine, PHP tries to locate the file on the Server machine ???

Whats wrong on my script????

Posted: Mon Jun 23, 2003 8:19 am
by mikusan
Nothing is wrong with your script... i am currently trying to accomplish the same thing...and ran into the same exact problem... i noticed just now this post... although i was more concerned with the form to retrieve the file path on the client computer i noticed that my php script spit out the same exact error.

Now PHP is server side know that... long ago, but perhaps me and you have a misconception on how the FTP works. I always thought FTP was the way to upload files from client to server, really, like CuteFTP that i use, but the code that i use comes up with the same error. Ideas?

After reading your post, i understand that another solution has to be made i will look into that. And whether you are intranet LAN or whatever it doesn't matter, don't get things complicated, the error you get is because PHP cannot get the file from the client PERIOD. Someone enlighten me on this one.

Hopefully someone can help me and the OP with this thing...in the meantime i am going to look at some opensource file uploader to get some insight... fsockopen??

Posted: Mon Jun 23, 2003 8:25 am
by mikusan
I wrote my previous reply while the manual page was loading, i suggest the OP would actually read what other people posted and not expect an out of the box solution, you must work at it yourself too...

i followed the link releasedj gave and i think that is the solution right there... now i am going to have to try it out before i talk... but thanks releasedj...

Posted: Mon Jun 23, 2003 9:56 am
by mikusan
Here finally got it to work...full code:
This is the form:

Code: Select all

<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="300000">
Send this file: <input name="userfile" type="file"><BR>
<input type="submit" value="Send File">
</form>
This is the php....

Code: Select all

<?php
// In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead of $_FILES.
// In PHP earlier then 4.0.3, use copy() and is_uploaded_file() instead of move_uploaded_file

$uploaddir = '/home/'; ///Your directory

print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])) {
    print "File is valid, and was successfully uploaded.  Here's some more debugging info:\n";
    print_r($_FILES);
} else {
    print "Possible file upload attack!  Here's some debugging info:\n";
    print_r($_FILES);
}

?>

Posted: Mon Jun 23, 2003 10:36 am
by Luis Almeida
I´ve used that script before and it work fine for file up to 100k but if file is longer than tha I get the message :

"The page cannot be displayed....."

It seem's that it can´t find the script "upload.php" to execute it
I thought that it was bacause of the MAX_POST_SIZE in PHP.ini but I´ve changet it to 50M and still getting the same error

Posted: Mon Jun 23, 2003 10:57 am
by m3rajk
i figured i should read this thread before trying that myself.... i have a few observations:

1-if i have a problem i should contact mikusan and if he's still having issues work with him to solve both of ours.

2- Luis is not getting what people are telling him and he's stuck on file size


Luis- get over file size. for now, pretend that doesn't exist. that you can upload a 50 terabyte file perfectly fine.

ok. my advice to you now is to read the manual supplied by released.

php and ftp are completely different. i'm not familiar enough with php to say there isn't a way to open an ftp connection in php, but your issue is that you're acting like you have an open ftp connection. php basically verifies and ALREADY uploaded file. there's ways in html via forms that one can get files uploaded.

when you're working on machine one, can you arbitrarily access files on macine 2??????
when was the last time you pulled the file remotely without first opening ftp or telnet???how can php do that when you can't???

Posted: Mon Jun 23, 2003 3:35 pm
by mikusan
okay d00d, i am working to get it to work, step by step, you can't expect everything Luis Almeida...

I have a similar problem, but at least i know it works...and that's a step forward... now since i am busy trying to figure this out why don't you chip in...look up some of the following vars...
max_post_size
max_input_time
max_execution_time
upload_max_filesize
limitrequestbody in apache

I am testing all this with a modem...so make yourself useful...

And it's not 100K the limit is the TIME it takes to run your script...

Posted: Mon Jun 23, 2003 3:37 pm
by releasedj
View the section in the manual link suppliad entitled "Common Pitfalls".
http://uk.php.net/manual/en/features.fi ... tfalls.php

It may help solve your problem with large files.

Posted: Mon Jun 23, 2003 3:40 pm
by mikusan
Is it possible to change those values arbitrarily throughout the execution of my site, seeing that i have no access to php.ini on my server?