 |
Your forum announcement here! |
|
 |

17-12-2006, 01:46
|
|
Junior Member
|
|
Join Date: Dec 2006
Posts: 2
|
|
Help with PHP File Upload Script
Hi,
I am new to eukhost and have been setting up a CMS for the backend of my company’s website and have written a very simple uploading script in php. So I was wondering if anyone can help me find out why I am getting these errors when it runs as it should work as it has run on my test server.
ERROR on site
Warning: move_uploaded_file(../Body/Staff/pauls.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/profound/public_html/Userarea/user.php on line 1341
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpFkU0Dd' to '../Body/Staff/pauls.jpg' in /home/profound/public_html/Userarea/user.php on line 1341
SCRIPT used
(staffimage : is the path passed to the script from the form)
$target_path = $target_path . basename( $_FILES['staffimage']['name']);
move_uploaded_file($_FILES['staffimage']['tmp_name'], $target_path);
$staffimageloc = $_FILES['staffimage']['name'];
Thanks for any help you can give
Kind Regards,
Ryan
|

17-12-2006, 22:54
|
|
Junior Member
|
|
Join Date: Dec 2006
Posts: 2
|
|
After talking to Andy on the live chat system we were able to solve the problem i was having. Once again thanks Andy
|

18-12-2006, 10:04
|
 |
Chief Marketing Officer
|
|
Join Date: Sep 2005
Posts: 4,261
|
|
Thats good to hear.
I was not able to figure out this problem yesterday so could not reply.
__________________
UK Web Hosting || Business Hosting || eUKhost Knowledgebase
Toll Free : 0808 262 0255 || MSN : mark @ eukhost.com || AIM : eukmark
A bunch of Sheep led by a Lion is better than a bunch of Lions led by a Sheep.
__________________________________________________
Great Opportunity :: Join our Affiliate Program for FREE and earn 20% commission on each referral.
|

08-01-2007, 00:04
|
|
Junior Member
|
|
Join Date: Jan 2007
Posts: 3
|
|
Similar Problem
Hi, I have a very similar problem as the one mentioned above. I get the following message listed below, and was wondering if someone would be able to help me with a solution. Thanks.
(I get the following message onced I've tried uploading something using my php form.)
Your file has been uploaded successfully! RUWar sincerely thanks you for your submission!
Warning: move_uploaded_file(/home/xunenet/public_html/test/upload/testfile.doc): failed to open stream: Permission denied in /home/xunenet/public_html/test/upload_file.php on line 25
Warning: move_uploaded_file(): Unable to move '/var/tmp/phphQEGJc' to '/home/xunenet/public_html/test/upload/testfile.doc' in /home/xunenet/public_html/test/upload_file.php on line 25
(I've attached a the php file I am using. I added the .txt file extension because .php is not allowed as a valid file extension for attachments in this forum.)
I hope someone is able to help me! 
|

08-01-2007, 11:55
|
 |
Chief Marketing Officer
|
|
Join Date: Sep 2005
Posts: 4,261
|
|
Hello Erika,
I am not able to figure out your domain name or account information. This seems to be due to rules in mod_security but let me know your domain name and I will get it sorted.
__________________
UK Web Hosting || Business Hosting || eUKhost Knowledgebase
Toll Free : 0808 262 0255 || MSN : mark @ eukhost.com || AIM : eukmark
A bunch of Sheep led by a Lion is better than a bunch of Lions led by a Sheep.
__________________________________________________
Great Opportunity :: Join our Affiliate Program for FREE and earn 20% commission on each referral.
|

08-01-2007, 14:31
|
|
Junior Member
|
|
Join Date: Jan 2007
Posts: 3
|
|
Domain Name
Hi,
My domain name is www. xune.net
Thanks for taking a look at it!
|

08-01-2007, 14:43
|
 |
Chief Marketing Officer
|
|
Join Date: Sep 2005
Posts: 4,261
|
|
You are not our customer so we wont be able to look into this problem.
__________________
UK Web Hosting || Business Hosting || eUKhost Knowledgebase
Toll Free : 0808 262 0255 || MSN : mark @ eukhost.com || AIM : eukmark
A bunch of Sheep led by a Lion is better than a bunch of Lions led by a Sheep.
__________________________________________________
Great Opportunity :: Join our Affiliate Program for FREE and earn 20% commission on each referral.
|

26-01-2007, 11:21
|
|
Junior Member
|
|
Join Date: Jan 2007
Posts: 6
|
|
Been having the same sort of issues. Been trying to sort it out via email, but its taking quite a while, so thought I would post here.
Been trying to sort out an uploader that works fine on my local environment, and with my old web hosts, but cant get it to work on my new webspace with eukhost.
Tried a number of other scripts, all giving the same issues.
uploaded a basic script to test.intervizual.net/uploadtest.php which contained the following:
Code:
form enctype="multipart/form-data" action="uploadtest1.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
"
This then calls uploadtest1.php when submit pressed
<?php
$uploaddir = '/attachments/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
However I get the following error message when I try to use the script. There is a folder called attachments on the server off the root, so this should be working as far as I can see - is this likely to be a config issue on the server?
Warning: move_uploaded_file(/attachments/beer-waterfall.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/interviz/public_html/test/uploadtest1.php on line 17
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpl0molY' to '/attachments/beer-waterfall.jpg' in /home/interviz/public_html/test/uploadtest1.php on line 17
Possible file upload attack!
Here is some more debugging info:Array
(
[userfile] => Array
(
[name] => beer-waterfall.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpl0molY
[error] => 0
[size] => 30644
Last edited by intervizual : 26-01-2007 at 11:25.
|

26-01-2007, 11:22
|
|
Junior Member
|
|
Join Date: Jan 2007
Posts: 6
|
|
Been having the same sort of issues. Been trying to sort it out via email, but its taking quite a while, so thought I would post here.
Been trying to sort out an uploader that works fine on my local environment, and with my old web hosts, but cant get it to work on my new webspace with eukhost.
Tried a number of other scripts, all giving the same issues.
uploaded a basic script to test.intervizual.net/uploadtest.php which contained the following:
<!--form enctype="multipart/form-data" action="uploadtest1.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
This then calls uploadtest1.php when submit pressed
<?php
$uploaddir = '/attachments/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
However I get the following error message when I try to use the script. There is a folder called attachments on the server off the root, so this should be working as far as I can see - is this likely to be a config issue on the server?
Warning: move_uploaded_file(/attachments/beer-waterfall.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/interviz/public_html/test/uploadtest1.php on line 17
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpl0molY' to '/attachments/beer-waterfall.jpg' in /home/interviz/public_html/test/uploadtest1.php on line 17
Possible file upload attack!
Here is some more debugging info:Array
(
[userfile] => Array
(
[name] => beer-waterfall.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpl0molY
[error] => 0
[size] => 30644
|

26-01-2007, 11:37
|
 |
Chief Marketing Officer
|
|
Join Date: Sep 2005
Posts: 4,261
|
|
Quote:
Originally Posted by eukhost.com
You are not our customer so we wont be able to look into this problem.
|
Please come on our livechat. Andy is here right now so he will help you to get this problem sorted.
__________________
UK Web Hosting || Business Hosting || eUKhost Knowledgebase
Toll Free : 0808 262 0255 || MSN : mark @ eukhost.com || AIM : eukmark
A bunch of Sheep led by a Lion is better than a bunch of Lions led by a Sheep.
__________________________________________________
Great Opportunity :: Join our Affiliate Program for FREE and earn 20% commission on each referral.
|

26-01-2007, 11:52
|
 |
Premium Member
|
|
Join Date: Jan 2007
Location: Amersham
Posts: 331
|
|
Quote:
Originally Posted by intervizual
<?php
$uploaddir = '/attachments/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
|
Hi - I use the following code to upload files - main difference appears to be that move-uploaded_file is done in a loop to give it time to complete. It's all done in a function storefile called like this:
Code:
//upload file
if($_FILES['resultsupload']['name']<>"") {
if(storefile("resultsupload", "../results/")) {
echo("Upload successful");
} else {
echo("Upload failed...");
}
}
The function is:
Code:
function storefile($var, $location, $filename=NULL, $maxfilesize=NULL) {
$ok = true;
if(isset($maxfilesize)) {
if($_FILES[$var]["size"] > $maxfilesize) {
$ok = false;
}
}
if($ok==true) {
$tempname = $_FILES[$var]['tmp_name'];
if(isset($filename)) {
$uploadpath = $location.$filename;
} else {
$uploadpath = $location.$_FILES[$var]['name'];
}
if(is_uploaded_file($_FILES[$var]['tmp_name'])) {
while(move_uploaded_file($tempname, $uploadpath)) {
// Wait for the script to finish its upload
}
}
return true;
} else {
return false;
}
}
One other thing is that my form has a hidden field MAX_FILE_SIZE which I don't think is absolutely necessary - but does mean the check is done client side
Hope this helps
David
|

12-02-2007, 08:25
|
|
Junior Member
|
|
Join Date: Jan 2007
Posts: 6
|
|
I did have the file upload script working - it seemed to be something to do with the permissions on the webserver.
Unfortunately, as of Friday / Saturday this week, its all stopped working again - same old permissions errors.
Tried getting it sorted yesterday via MSN - unfortunately the tech support bod asked what the problem was and then went afk and never got back to me.
Have the server permissions been altered in the last week?
|

12-02-2007, 08:59
|
 |
Chief Marketing Officer
|
|
Join Date: Sep 2005
Posts: 4,261
|
|
nope. We never make any permission changes.
It may be due updates in security settings but if you let me know where you are getting error then I can remove those security rules. I will need to produce the error to see logs in error_logs of apache.
__________________
UK Web Hosting || Business Hosting || eUKhost Knowledgebase
Toll Free : 0808 262 0255 || MSN : mark @ eukhost.com || AIM : eukmark
A bunch of Sheep led by a Lion is better than a bunch of Lions led by a Sheep.
__________________________________________________
Great Opportunity :: Join our Affiliate Program for FREE and earn 20% commission on each referral.
|

12-02-2007, 10:23
|
|
Junior Member
|
|
Join Date: Jan 2007
Posts: 6
|
|
OK, sent you a message from website to give you the details of the problem, and login details so you can recreate the problem.
|

12-02-2007, 10:52
|
 |
Chief Marketing Officer
|
|
Join Date: Sep 2005
Posts: 4,261
|
|
May I know the ticket number ?
It wont remain on the board for me to find if you don't give the ticket number after opening the ticket.
__________________
UK Web Hosting || Business Hosting || eUKhost Knowledgebase
Toll Free : 0808 262 0255 || MSN : mark @ eukhost.com || AIM : eukmark
A bunch of Sheep led by a Lion is better than a bunch of Lions led by a Sheep.
__________________________________________________
Great Opportunity :: Join our Affiliate Program for FREE and earn 20% commission on each referral.
|

12-02-2007, 11:07
|
|
Junior Member
|
|
Join Date: Jan 2007
Posts: 6
|
|
#bou-45348-571
|

12-02-2007, 11:26
|
 |
Chief Marketing Officer
|
|
Join Date: Sep 2005
Posts: 4,261
|
|
Nick solved your problem. Please ignore my reply to the ticket.
I unnecessarily got on it.
__________________
UK Web Hosting || Business Hosting || eUKhost Knowledgebase
Toll Free : 0808 262 0255 || MSN : mark @ eukhost.com || AIM : eukmark
A bunch of Sheep led by a Lion is better than a bunch of Lions led by a Sheep.
__________________________________________________
Great Opportunity :: Join our Affiliate Program for FREE and earn 20% commission on each referral.
|

12-02-2007, 11:36
|
|
Junior Member
|
|
Join Date: Jan 2007
Posts: 6
|
|
Thanks  Can you drop me a PM letting me know what the issue was, incase it occurs again
|

12-02-2007, 11:50
|
 |
Chief Marketing Officer
|
|
Join Date: Sep 2005
Posts: 4,261
|
|
He changed permission of your attachments folder to 777. Your php scripts were trying to write to it and 755 permission was preventing them from writing. He gave 777 permission to sort it.
__________________
UK Web Hosting || Business Hosting || eUKhost Knowledgebase
Toll Free : 0808 262 0255 || MSN : mark @ eukhost.com || AIM : eukmark
A bunch of Sheep led by a Lion is better than a bunch of Lions led by a Sheep.
__________________________________________________
Great Opportunity :: Join our Affiliate Program for FREE and earn 20% commission on each referral.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 15:27.
|
|
|