File uploads not working

This is a discussion on File uploads not working within the PHP Language forums, part of the PHP Programming Forums category; I am trying a simple file upload, but cannot make it work on my localhost. I wrote the following code: $...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-10-2005
James Arnall
 
Posts: n/a
Default File uploads not working

I am trying a simple file upload, but cannot make it work on my
localhost. I wrote the following code:


$strFileDir = "/images/gallery/";
$strFileName = $strFileDir . $_FILES['fImage']['name'];
if (move_uploaded_file($_FILES['fImage']['tmp_name'],$strFileName));
{
echo ("Success");
}

....but get the following errors when uploading "gallery_1.gif":

Warning: move_uploaded_file(/images/gallery/gallery_1.gif): failed to
open stream: No such file or directory in
C:\Development\ChasityChase.com\www\admin\image\im age.php on line 16

Warning: move_uploaded_file(): Unable to move
'C:\PHP\uploadtemp\phpE4.tmp' to '/images/gallery/gallery_1.gif' in
C:\Development\[sitename]\www\admin\image\image.php on line 16
/images/gallery/gallery_1.gif

I am working in Windows XP Pro/IIS, in case you couldn't tell.

Thanks in advance,
james
Reply With Quote
  #2 (permalink)  
Old 01-10-2005
Paul Barfoot
 
Posts: n/a
Default Re: File uploads not working

Hi James

You will need to give the full path of where you want the file moved to.

$strFileDir = "/images/gallery/"; won't work

$strFileDir = "c:/path/to/files/images/gallery/"; should work

--
Paul Barfoot


"James Arnall" <news@jamesarnall.com> wrote in message
news:VvqdnX0-nsCcc3_cRVn-1w@comcast.com...
>I am trying a simple file upload, but cannot make it work on my localhost.
>I wrote the following code:
>
>
> $strFileDir = "/images/gallery/"; $strFileName = $strFileDir .
> $_FILES['fImage']['name'];
> if (move_uploaded_file($_FILES['fImage']['tmp_name'],$strFileName));
> {
> echo ("Success");
> }
>
> ...but get the following errors when uploading "gallery_1.gif":
>
> Warning: move_uploaded_file(/images/gallery/gallery_1.gif): failed to open
> stream: No such file or directory in
> C:\Development\ChasityChase.com\www\admin\image\im age.php on line 16
>
> Warning: move_uploaded_file(): Unable to move
> 'C:\PHP\uploadtemp\phpE4.tmp' to '/images/gallery/gallery_1.gif' in
> C:\Development\[sitename]\www\admin\image\image.php on line 16
> /images/gallery/gallery_1.gif
>
> I am working in Windows XP Pro/IIS, in case you couldn't tell.
>
> Thanks in advance,
> james



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:43 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0