hello,
i have used the following code for file upload:

$id=100;

$upload_dir = "images/";

do
{
		$photo = $_FILES['photo'];
		
		switch($photo['error'])
		{
			case UPLOAD_ERR_INI_SIZE:
				$err2 = "Server doesn't allow the image size.. Please select a smaller one..";
				break 2;
			case UPLOAD_ERR_PARTIAL:
				$err2 = "The image was not transferred successfully..";
				break 2;
			case UPLOAD_ERR_NO_FILE:
				break 2;
			case UPLOAD_ERR_FORM_SIZE:
				$err2 = "The size of the image was too large..";
				break 2;
			case UPLOAD_ERR_OK:
				break;
			default:
				$err2 = "Some error occured while uploading the image..";
				break;
		}

		$ext = substr(strrchr($photo['name'], "."),1);
		if(!($ext == "bmp" || $ext == "jpg" || $ext == "jpeg" || $ext == "jpe" || $ext == "gif" || $ext == "png"))
		{
			$err2 = "Invalid image type.. Please select a JPG, BMP, GIF or PNG image..";
			break;
		}

		$upload_path = $upload_dir . $id . "." . $ext;
		if(!@move_uploaded_file($photo['tmp_name'], $upload_path))
		{
			$err2 = "Error moving file to its destination..";
		}
		
}
while(0);	

print "" . $err2;


The html code is like:

<form name="addartcraft" action="activities.php?sub=artcraft" enctype="multipart/form-data" method="post">
	<input type="hidden" name="MAX_FILE_SIZE" value="5242880" />
	<input type="file" name="photo" />
	<input name="addartcraft" type="submit" value="Save" />
</form>


This works perfectly on my localhost..

But when i uploaded the site, the error occurs..

i have subscribed web space on Yahoo!

in Yahoo! file manager, the uploaded file is shown, but it doesn't be opened..

The screenshot is attached..

The directory's access permission is Public already..

and i also tried chmod(), but didnt find the solution..

Screenshot:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.