Jump to content

PHP Image Upload Problem


kpetsche20

Recommended Posts

I'm trying to make a script that allows me to upload a image to my sever from a form then have it put into a folder that is associated with a specific username.

 

When I try to upload I get an error

 

Warning: move_uploaded_file(/home/bluearro/public_html/imageupload/images/Static_Cuz(2).jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/bluearro/public_html/imageupload/handle.php on line 8

 

 

 

Here is a link to the script, the problem can be replicated in 5 seconds.

 

http://bluearrowhosting.com/imageupload/

 

 

Here's the code

<?php
$target = "/home/bluearro/public_html/imageupload/images";
	$target .= $_POST['login']."/";
	$target2 = $target.$_FILES['file']['name'];
	$ok=1;
if (!is_dir($target)) mkdir($target,0777);

$new=move_uploaded_file($_FILES['file']['tmp_name'], $target2);
$ext=getExtension($_FILES['file']['name']);
$goodext = array('jpg','jpeg','png','bmp','gif');
if (in_array($ext,$goodext)) $extcheck=true;
$size=filesize($_FILES['file']['tmp_name']);
$height=$randomsss[0]=getimagesize($target2);
$width=$randomsss[1]=getimagesize($target2);
if ($width<120 && $height<100) $sizecheck=true;
if ($size < $MAX_SIZE*1024 && $new == true && $extcheck==true && $sizecheck == true) echo "The file ". basename( $_FILES['file']['name']). " has been uploaded";
else {
echo "Sorry, there was a problem uploading your file."; 
if ($size > $MAX_SIZE*1024)
{echo " It seems that your file is too big.";}
else if ($extcheck == false)
{echo " It seems you tried to upload an unallowed file type. ";echo $ext;}
else if ($sizecheck==false)
{echo "The width and/or height are too big.";}}


?>

Link to comment
Share on other sites

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.