Upload file error message

Cannot upload photos unto a directory

Page 1 of 1

2 Replies - 3039 Views - Last Post: 03 October 2006 - 05:26 PM Rate Topic: -----

#1 david4u  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 38
  • Joined: 26-April 06

Upload file error message

Posted 03 October 2006 - 07:46 AM

Hello Everyone,
I have tried to upload photos using php code but keeps bring this error message below:


Warning: move_uploaded_file(upload/img452274d6aba97.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\wamp\www\WEB\GLORY\flexaccom\uploadfile.php on line 65

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'c:/wamp/tmp\phpF7.tmp' to 'upload/img452274d6aba97.jpg' in C:\wamp\www\WEB\GLORY\flexaccom\uploadfile.php on line 65


This is the code for upload that I used:

[/

function uploadFile($source)
{
$uploadpath = 'upload/';
// $source = $HTTP_POST_FILES[$filename]['tmp_name'];
$dest = '';

if ( ($source != 'none') && ($source != '' )) {

$imagesize = getimagesize($source);

switch ( $imagesize[2] ) {

case 0:

// Image is unknown <BR>';
break;

case 1:
// Image is a GIF
$dest = $uploadpath.uniqid('img').'.gif';
break;

case 2:
// Image is a JPG <BR>'
$dest = $uploadpath.uniqid('img').'.jpg';
break;

case 3:
// Image is a PNG <BR>'
$dest = $uploadpath.uniqid('img').'.png';
break;
}


if ( $dest != '' ) {

if ( move_uploaded_file( $source, $dest ) ) {
return $dest;
}
}
else
return '';
}
}

]

Can anyone help please?

Is This A Good Question/Topic? 0
  • +

Replies To: Upload file error message

#2 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: Upload file error message

Posted 03 October 2006 - 12:21 PM

Where does $filename come from? Where is it defined?
Was This Post Helpful? 0
  • +
  • -

#3 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1148
  • View blog
  • Posts: 7,149
  • Joined: 07-September 06

Re: Upload file error message

Posted 03 October 2006 - 05:26 PM

Okay I am assuming that $dest is the destination in which case you are telling it to move the image file to a .(extension) so it will attempt to move it to a folder.png for example.

This code:

case 1: 
// Image is a GIF
$dest = $uploadpath.uniqid('img').'.gif'; 
break; 

case 2: 
// Image is a JPG <BR>'
$dest = $uploadpath.uniqid('img').'.jpg'; 
break; 

case 3: 
// Image is a PNG <BR>'
$dest = $uploadpath.uniqid('img').'.png'; 
break; 
}


SHould look something like this:
case 1: 
// Image is a GIF
$dest = $uploadpath.uniqid('img').'/gif/'; 
break; 

case 2: 
// Image is a JPG <BR>'
$dest = $uploadpath.uniqid('img').'/jpg/'; 
break; 

case 3: 
// Image is a PNG <BR>'
$dest = $uploadpath.uniqid('img').'/png/'; 
break; 
}


If I am thinking right.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1