Jump to content

Uploading Image problem


The14thGOD

Recommended Posts

I'm having a problem of uploading an image, it keeps saying the file is not the correct size..but it is the same size. Perhaps I'm missing something? Or perhaps a server/php reads the size a little different?

 

here's the code if anyone can take a look at it and help me id be very great full:

<?php
import_request_variables('pg');	
//First check that file ext = .jpg then rename file and location, also upload to perminate location{
$extension = explode('.',$_FILES['photo']['name']);
if ($extension[1] == 'jpg') {
	$uploaddir = '../images/news/';
	$filename = $_FILES['photo']['name'];
	$file_dir = "$uploaddir" . "$filename";
	move_uploaded_file($_FILES['photo']['tmp_name'], "$file_dir");
	$size = getimagesize($file_dir);
	if($size[0] != 334 or $size[1] != 184) {
		$error = 'file';
		unlink($file_dir);
		header("Location: add_news.php?error=$error");
		exit(0);
	}
	$size_true = 'true';
}
elseif ($extension[1] !== 'jpg' or !$size_true) {
	$error = 'file';
	header("Location: add_news.php?error=$error");
	exit(0);
}?>

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/56909-uploading-image-problem/
Share on other sites

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.