Jump to content

[SOLVED] Im Losing it ! Whats going on here !


Recommended Posts

So i have this script ! as simple as it gets to upload an image.

I got it working all fine with no errors or anything ...

uploaded the image just fine, and inserted into the DB just as well.

I've ran the script on a few occasions with no problems and today

i get in, run the script and voila ! WONT WORK ! what is that about.

 

The only change to the server was a cPanel update, as far as i know!

 

If you have any clue why this may be please toss it my way ! Thanks

 

The Script !

<?

include('../connect2db.php');

$action =  isset($_POST['action']) ? $_POST['action'] : null;
if (!is_null($action)) 
{
	$action = $_POST['action'];
}


if($action == "insert") // IF INSERT THEN UPLOAD THE IMAGE THAT WAS POSTED TO THIS POINT
{

	$userfile_name = $_FILES['image']['name']; // filename
	$userfile_tmp = $_FILES['image']['tmp_name']; // temp filename
	$userfile_size = $_FILES['image']['size']; // file size
	$userfile_type = $_FILES['image']['type']; // file type... jpg, gif, etc...

	$placefiledir = 'upload/newsletters/'; // Directory where image will be uploaded to

	$prod_img = $placefiledir . $userfile_name; // path/imgname.jpg

	if (isset($_FILES['image']['name'])) // if the array isnt empty upload the file
		{
			if(move_uploaded_file($userfile_tmp, $prod_img)) // Upload the image file
				{
					//print_r($_FILES); // prints out $_FILES array content

					//echo $userfile_name . "<BR>";

					$takeoffext = substr($userfile_name, 0, -4);
					$htmlfilename = $takeoffext . ".HTML";

					//echo $htmlfilename;

					$query = "INSERT INTO e_newsletters (htmlfile, thumbfile, timestamp, date) VALUES ('$htmlfilename', '$userfile_name', CURRENT_TIMESTAMP(), now())";
					$sql = mysql_query($query) or die('Error with e_newsletter query ' . mysql_error());
					?><meta http-equiv=refresh content='0;url=index.php'><?
				}	
			else
				{
					echo "COULD NOT UPLOAD IMAGE <BR><BR>";
					print_r($_FILES);
				}			
		}
	else
		{
			echo "You did not chose an image to upload !";
			//print_r($_FILES); // prints out $_FILES array content
			?><meta http-equiv=refresh content='3;url=javascript:history.go(-1)'><?

		}	

}
else // IF NOT INSERT OR ANYTHING ELSE, SHOW THE UPLOAD FORM
{
	?>
        <h2>  Add e-Newsletter...</h2>
	<table cellpadding="3" cellspacing="0" border="0" style="border: 1px solid #CCCCCC; background-color: #EEEEEE;" width="20%">
	<tr>
	<form action="admin_newsletters.php" method="post" enctype="multipart/form-data">
	<td align="center">
	<input type="file" name="image" id="image" /><br />
        <input type="hidden" name="action" value="insert" />
	<input type="submit" value="Upload eNewsletter" />
	</td>
	</form>
	</tr>
	</table>
        <?
}
?>

 

the print_r($_files) returns

 

Array ( [image] => Array ( [name] => 100407_HANDTRK.jpg [type] => image/pjpeg [tmp_name] => /tmp/phpQSgJEn [error] => 0 => 60190 ) )

 

Thanks 2 All !

Link to comment
https://forums.phpfreaks.com/topic/71817-solved-im-losing-it-whats-going-on-here/
Share on other sites

Here's the error from my cPanel Error Log...

 

[error] PHP Warning:  move_uploaded_file(upload/newsletters/100407_HANDTRK.jpg) [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: failed to open stream: No such file or directory in /home/globinfo/public_html/admin/admin_newsletters.php on line 30

 

 

i've heard of this failed to open stream: error before but no clue how to fix it yet.

 

 

 

EDIT =====

 

 

GOT IT WORKIN TY ALL

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.