Jump to content

Picture upload problems


Steppio

Recommended Posts

I'm having a few problems uploading jpegs and moving them into a new folder. I've looked all over the web for help and scanned the code a hundred times, so i think its time to ask for some help:

 

if ($_FILES['usefile']['error'] > 0)
{
echo 'Problem: ';
	switch ($_FILES['usefile']['error'])
	{
		case 1: echo 'File exceeded upload_max_filesize'; break;
		case 2: echo 'File exceeded max_file_size'; break;
		case 3: echo 'File only partially uploaded'; break;
		case 4: echo 'No file uploaded'; break;
	}
	exit;
}


if ($_FILES['userfile']['type'] != 'image/jpeg')
{
	echo 'Problem: File is not a picture';
	exit;
}


$currentdir=getcwd();
$target_path = $currentdir . "\\upload\\images\\" . basename($_FILES['userfile']['name']);
echo "Target: $target_path<br>";
$temploc=$_FILES['userfile']['tmp_name'];
echo "Temploc: $temploc<br>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['userfile']['name']). " has been uploaded<br><br>";
} else {
    echo "There was an error uploading the file, please try again!<br><br>";
}

 

The error i am receiving upon trying to move this file is:

 

Target: C:\Program Files\Apache Group\Apache\htdocs\trans\upload\images\Windscreen.jpg

Temploc: C:\WINDOWS\Temp\php137.tmp

 

Warning: move_uploaded_file(C:\Program Files\Apache Group\Apache\htdocs\trans\upload\images\Windscreen.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\Program Files\Apache Group\Apache\htdocs\trans\add_product.php on line 77

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\php137.tmp' to 'C:\Program Files\Apache Group\Apache\htdocs\trans\upload\images\Windscreen.jpg' in C:\Program Files\Apache Group\Apache\htdocs\trans\add_product.php on line 77

There was an error uploading the file, please try again!

 

I really am at my wits end, any help would be greatly appreciated.

Thanks in advance for your time.

 

Steppio

Link to comment
https://forums.phpfreaks.com/topic/102303-picture-upload-problems/
Share on other sites


if($_POST["submit"]=='submit'){
if ($_FILES["file"]["type"] == "image/jpeg")
{

if ($_FILES['userfile']['error'] > 0)
{
echo 'Problem: ';
	switch ($_FILES['userfile']['error'])
	{
		case 1: echo 'File exceeded upload_max_filesize'; break;
		case 2: echo 'File exceeded max_file_size'; break;
		case 3: echo 'File only partially uploaded'; break;
		case 4: echo 'No file uploaded'; break;
	}
	exit;
}
}	

//if ($_FILES['userfile']['type'] = 'image/jpeg')
//	{
//		echo 'Problem: File is not a picture';
//		exit;
//	}


$currentdir=getcwd();
$target_path = $currentdir . "\\upload\\images\\" . basename($_FILES['userfile']['name']);
echo "Target: $target_path<br>";
$temploc=$_FILES['userfile']['tmp_name'];
echo "Temploc: $temploc<br>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['userfile']['name']). " has been uploaded<br><br>";
} else {
    echo "There was an error uploading the file, please try again!<br><br>";
}
}

?>
<html><body>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="userfile" id="userfile" />
<input  type="submit" name="submit" value="submit" />
</form></body></html>

Darkwater ... i love you. I want to somehow produce offspring from you. They can share my total lack of perception and your lovely cranium.

I literally cannot believe it all came down to that, 1 missing 's' (the folder name was //uploads//). I don't know how to thank you, i must have looked over that page (it's based on about 4 different form PHP_SELF reloads) a hundred times and never saw that.

Your a star mate, got me out a diddley of a pickle there.

Again - THANK YOU!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.