Click to See Complete Forum and Search --> : hlp with file upload


katasova
11-30-2005, 11:01 PM
Hi evreyone, i need to upload an image to my server but i dont know why it is not working...

this is my code


$target_path = 'http://www.server.com.mx/mailer/Files/';
$target_path = $target_path . basename( $_FILES['archive']['name']);
move_uploaded_file($_FILES['archive']['tmp_name'], $target_path);



The coomon way i upload archives is via ftp and the server have password, i dont know if i need something special in order to upload files from a php file..

All my code work flawless in localhost...

Any advice to fix this?

Thx a lot...

Ohhh if u need to see the error message plz tell me and i will post it

SpectreReturns
12-01-2005, 12:57 AM
Always post the error message. I suspect your problem is that you're trying to move the files to a non-local address.

katasova
12-01-2005, 01:31 AM
This are the errors...

Warning: move_uploaded_file(mailer/Files/Invierno.jpg): failed to open stream: No such file or directory in \\172.21.6.15\s003\okidata.com.mx\mailer\upload.php on line 24

Warning: move_uploaded_file(): Unable to move 'C:\WINDOWS\TEMP\php14AB.tmp' to 'mailer/Files/Invierno.jpg' in \\172.21.6.15\s003\okidata.com.mx\mailer\upload.php on line 24

katasova
12-01-2005, 01:33 AM
oops it was a modify version of the original one....

the original version have this path...

Warning: move_uploaded_file(http://www.okidata.com.mx/mailer/Files/Invierno.jpg): ...

chong
12-01-2005, 01:53 AM
try using a relative target path, not a url

katasova
12-01-2005, 01:55 AM
excuse my ignorance what is a relative target path? is that the ip address?
x.x.x.x :confused: if it is i will use ping to find it hehe

Sheldon
12-01-2005, 03:27 AM
try

<?php
//make sure this is the first code on the page
@error_reporting('E_ALL');
@ini_set('display_errors', '1');

// now do the upload anywhere after it.
$path = '/mailer/Files/';
$target_path = $path . basename( $_FILES['archive']['name']);
if(move_uploaded_file($_FILES['archive']['tmp_name'], $target_path)){
print 'uploaded : '.$target_path;
}else{
print 'there was this big error';
}



ALWAYS DEBUG



Debug, Debug and Debug it will solve the problem every time.

katasova
12-01-2005, 09:39 AM
i did what u suggested but still throw this to warnings and do not upload the file....



Warning: move_uploaded_file(http://www.okidata.com.mx/mailer/Files/Colinas azules.jpg): failed to open stream: HTTP wrapper does not support writeable connections. in \\172.21.6.15\s003\okidata.com.mx\mailer\upload.php on line 30

Warning: move_uploaded_file(): Unable to move 'C:\WINDOWS\TEMP\php14D3.tmp' to 'http://www.okidata.com.mx/mailer/Files/Colinas azules.jpg' in \\172.21.6.15\s003\okidata.com.mx\mailer\upload.php on line 30




I think it might be some kind of mistake on the php configuration of the company i got the service from....

Do u know if it is possible or it is just a code mistake?

katasova
12-01-2005, 10:16 AM
thx a lot for ur hlp i called the company where i store my page and the noobs told me wrong the file where i have write permissions :mad:

So all the problem was write permissions....

Thx a lot for ur time guys

bokeh
12-01-2005, 11:00 AM
$target_path = 'http://www.server.com.mx/mailer/Files/';
$target_path = $target_path . basename( $_FILES['archive']['name']);
move_uploaded_file($_FILES['archive']['tmp_name'], $target_path);The $target_path must be a server file path. Http paths maybe used for opening files but they certainly cannot be used in write mode.