/    Sign up×
Community /Pin to ProfileBookmark

Uploading Images…and you…

Ok, so here’s my problem:

I setup this thing in php to upload images to a directory for some newsletter thing. It was working swimmingly until the other day when some idiot messed with something apparently. Now it’s giving me errors out the butt…

Here’s the errors:

I get the following error when I attempt to upload an image <100kb:

[quote]

Warning: move_uploaded_file(/usr2/web/admissions/tigersintouch/images/uploads/08162006-o-planning.png): failed to open stream: Permission denied in /usr2/web/admissions/tigersintouch/admin/includes/sections/upload.php on line 23

Warning: move_uploaded_file(): Unable to move ‘/tmp/php9hwta6’ to ‘/usr2/web/admissions/tigersintouch/images/uploads/08162006-o-planning.png’ in /usr2/web/admissions/tigersintouch/admin/includes/sections/upload.php on line 23
There was a problem when attempting to upload a new picture.
Send the following to the administrator:

Array
(
[userfile] => Array
(
[name] => o-planning.png
[type] => image/png
[tmp_name] => /tmp/php9hwta6
[error] => 0
[size] => 88794
)

)

[/quote]

If I attempt to upload an image >100kb, it basically gives me one of those “Connection Reset” errors in Firefox.

I’m not sure exactly what’s causing these problems, but if someone could shed some insight, that would be greatly appreciated.

Thanks, guys,

Will ?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@tgrk35authorAug 16.2006 — What the heck, I'll even give you the address for it ?.

http://www.fhsu.edu/admissions/tigersintouch/admin

?
Copy linkTweet thisAlerts:
@tgrk35authorAug 16.2006 — You think this might be a permission problem?
Copy linkTweet thisAlerts:
@tgrk35authorAug 17.2006 — Ok, so I changed some permissions and such around, but here's what I'm still getting:


move_uploaded_file(/usr2/web/admissions/tigersintouch/images/uploads/08172006-bg2.png): failed to open stream: Permission denied in /usr2/web/admissions/tigersintouch/admin/includes/sections/upload.php on line 23

Warning: move_uploaded_file(): Unable to move '/tmp/phpwkCThl' to '/usr2/web/admissions/tigersintouch/images/uploads/08172006-bg2.png' in /usr2/web/admissions/tigersintouch/admin/includes/sections/upload.php on line 23
[/quote]


Here's the actual code for the entire page:

[code=php]
<?php

echo '<h6 class="header" style="margin-bottom: 20px;">';
echo 'Image Upload';
echo '</h6>';

if ($_POST['filesubmit'])
{
$date = date('mdY',time());

$uploaddir = $_SERVER['DOCUMENT_ROOT'] . '/admissions/tigersintouch/images/uploads/';
$uploadfile = $uploaddir . $date . '-' . basename($_FILES['userfile']['name']);

echo '<div style="width: 495px; float: right; padding: 5px;">';

if (!preg_match('/[jpg$|gif$|jpe$|jpeg$|png$]/i',$_FILES['userfile']['name']))
{
echo 'Sorry, you must submit either a .gif, .jpg, .jpeg, .jpe, or .png file.';

}
else
{
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{
echo 'Your file was successfully uploaded. To insert it into a new snippet, please use the following path:';
echo '<br /><br />';
echo '<strong>';
echo '/admissions/tigersintouch' . substr($uploadfile,2);
echo '</strong>';
}
else
{
echo 'There was a problem when attempting to upload a new picture.';
echo '<br /><br />';
switch ($_FILES['userfile']['error'])
{
case '2':
echo 'The file you attempted to upload is <strong>larger than 100kb</strong>. <br />Please hit the back button and try again.';
break;
}

// DEBUGGING INFO
/*
echo '<pre style="margin-left: 50px; font-weight: bold; text-align: left;">';
print_r($_FILES);
echo '</pre>';
*/
}

echo '</div>';
}
}
else
{
echo '<h6 style="margin-bottom: 5px; width: 504px; text-align: left; margin-left: 30px; float: right; font-size: 120%; border-bottom: 1px solid #000;">';
echo 'Select your file...';
echo '</h6>';

echo '<span style="width: 465px; display: block; float: right; margin-bottom: 10px; ">';
echo 'You may only upload GIF, JPG, JPE, JPEG, and PNG files at this time. If the form immediately fails, you might be trying to upload too large of a file. The maximum file size allowed is 100kb. Any files with the same name uploaded on the same day will be <strong>overwritten.</strong>';
echo '</span>';

echo '<form enctype="multipart/form-data" action="index.php?section=upload" method="post">';
echo '<input type="hidden" name="MAX_FILE_SIZE" value="100000" />';

echo '<input name="userfile" id="userfile" type="file" size="55" />';

echo '<input class="standard" style="margin-left: 5px;" type="submit" name="filesubmit" value="Upload" />';

echo '</form>';
}

?>
[/code]


As of now I have the upload directory set to 775. I've got the upload.php set to 664.

I've set this page up in a different directory and it works perfectly with the same chmod and grp permissions (unix)...not sure why.

Anyone have any ideas on this? I had this thing working perfectly, but then suddenly I think someone did something to the server and it went messed up ?.

Thanks, guys.
×

Success!

Help @tgrk35 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...