RE: [PHP-GENERAL] WHY does file upload work only on local server
| From: | Chris Sano | Date: | Sun, 04 Jun 2000 22:11:39 +0000 |
| Subject: | RE: [PHP-GENERAL] WHY does file upload work only on local server | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1001@lists.php.net to get a copy of this message | ||
Helmut,
I had some trouble with that earlier. What it is saying is that the image,
c:\images\image1.jpg does not exist in /u/web/quarti/system_htm/aw.php3
(/u/web/quarti/system_htm/c:\images\image1.jpg).
You need to strip down the path to its pure filename before doing this. In
order to do this, you will need to use the block of code below:
$image_name = "c:\images\image1.jpg";
// this will read the data up to the backslashes, then split them
// c: will go into image_info[0], images will go into image_info[1],
image1.jpg will go into image_info[2]
$image_info = split("\\\\", $image_name);
// this counts how many cells have been filled in the $image_info array
$image_count = count($image_info);
// retrieves the image file name ($image_count-1 is used because the array
starts with 0 while count starts with 1)
// chop gets rid of white space
$image_str = chop($image_info[($image_count - 1)]);
// this is the path on the server you want the image to be saved in.
image_str is the file name.
$image_file = "images/" . $image_str;
// this will save c:\images\image1.jpg to
/u/web/quarti/system_htm/images/image1.jpg
copy($image_name, $image_file);
Hope this helps!
Chris
-----Original Message-----
From: helmut ott [mailto:haott@freenet.de]
Sent: Sunday, June 04, 2000 4:38 PM
To: php-general@lists.php.net
Subject: [PHP-GENERAL] WHY does file upload work only on local server
Tricky image uploading.
Everything works fine on my local server. But on the remote server the
scripts wants to find the local file path on the remote server?!
(E.g. I have a file input field and enter the local file path of the image
to be uploaded, e.g. c:/images/image1.jpg.
When I submit the form the script replies :
"...
Warning: Unable to open 'c:\images\image1.jpg for reading: No such file or
directory in /u/web/quarti/system_htm/aw.php3 on line ..." (which is the
path of my remote server, where my php-script is)
So how can I make the server (apache/unix) read the file in the local
source-directory and then upload it (which works without any problems when I
run the script on my local server pointing to another directory containing
an image-file).
Does anybody know the TRICK?
Thanks alot
Helmut