Tuesday, 17 September 2013

uploading image file error

uploading image file error

this php script is retuning errors when I try and upload a file. I'm using
XAMPP on a win xp machine. I believe I've set sharing permissions
correctly.
the script:
//For images
if (isset($_FILES['image300x100']) &&
!empty($_FILES['image300x100']['tmp_name'])) {
$name = $_FILES['image300x100']['name']; // getting the name of the file
$tempName = $_FILES['image300x100']['tmp_name']; // getting the
temporary file name.
$allowedExt = array('jpg', 'jpeg', 'png', 'gif' );// specifying the
allowed extentions
$a = explode('.', $name);
$fileExt = strtolower(end($a)); unset($a);//
$fileSize = $_FILES['image300x100']['size'];
$filePath = "";
switch($category){
case 1 : $filePath =
"c:/www/Perspect/categories/politics/articleImages"; break;
//etc etc etc
}
$path = $filePath;
} else{
$errors[] = 'no file selected';
}
$moveResult = move_uploaded_file($tempName, $filePath);
left as it is the error is:
Warning: move_uploaded_file(): The second argument to copy() function
cannot be a directory in C:\www\Dev\admin\addNewArticle.php on line 62
Warning: move_uploaded_file(): Unable to move
'C:\Server\XAMPP\tmp\php62C.tmp' to
'c:/www/Dev/categories/bla/articleImages' in
C:\www\Dev\admin\addNewArticle.php on line 62
I removed the c:/from the path which I thought was the correct path but
that gave a result of:
temp nameC:\Server\XAMPP\tmp\php62E.tmp filepath
www/Dev/categories/bla/articleImages
Warning: move_uploaded_file(www/Dev/categories/bla/articleImages): failed
to open stream: No such file or directory in
C:\www\Dev\admin\addNewArticle.php on line 62
Warning: move_uploaded_file(): Unable to move
'C:\Server\XAMPP\tmp\php62E.tmp' to 'www/Dev/categories/bla/articleImages'
in C:\www\Dev\admin\addNewArticle.php on line 62
Any help hugely appreciated

No comments:

Post a Comment