Page 1 of 1

upload manager problem ... [Solved]

Posted: Tue Nov 28, 2006 4:37 am
by zenny
hi guys, i am beginner in php and have tried to make a download manager. However, my download manager works on my local apache svr but when i tried to upload it up to my webhost it didn't work. I've even enabled chmod 777 to allow full write capability, but it still do not work out. Below is my full upload manager code, i appreciate any help possible. Thanks in advance

Code: Select all

<?php

define ("FILEDIRECTORY", "/addo");
$MaxSize = 5000;
$noFilename = "";
$getFilename = $_REQUEST['name'];
//check if it is posted by the form, and name field is entered
 if (is_uploaded_file($_FILES['addon']['tmp_name'])) {

	if($_FILES['addon']['size'] > $MaxSize) { //check max file size
	
	echo "<p> Max File Size Exceeded 5mb, please try again or contact admin@raidsg.net.</p>";
	
	}
	
	else if ($getFilename == $noFilename) { //check that filename is entered
	
		echo "<p>Please enter a File name for upload</p>";
		}
	
	else if ($_FILES['addon']['type'] != "application/x-zip-compressed") { 
	             //check that the correct format is entered
	echo "Please zip up your file with WinZip";
	 } else {  
	
	$name = $_POST['name'];
	
	//upload zip file.
	$result = move_uploaded_file($_FILES['addon']['tmp_name'], FILEDIRECTORY."/$name.zip");
	$desc = $_REQUEST['Discribe'];
	
	//opening text file to write and save discription.
	$resource = fopen(FILEDIRECTORY."/$name.txt", "wt");
	fwrite($resource, $desc, "15000");
	fclose($resource);
	if ($result == 1)  { 
	
	
	//display uploaded item.
	$uploadDESC = fopen(FILEDIRECTORY."/$name.txt", "r");
	$theData = fread($uploadDESC, "15000");
	fclose($uploadDESC);
	echo "<p> File Uploaded Successfully.</p>";
	echo "<p> You have uploaded $name.zip with the description below : </p>";
	echo "<p> $theData </p>"; 
	
	}
		else echo "<p> There was a problem, during uploading process.</p>";
	} #endIF
	
  }#endIF



?>

hoster

Posted: Tue Nov 28, 2006 5:33 am
by Jaxolotl
did you check that the server you're parsing the script allows a 5Mb upload from script?
post_max_size and upload_max_filesize on php ini

you can check this by writing a php file with only this code inside

Code: Select all

<?php
phpinfo();
?>
you have almost all the environment settings of the platform you're running the script

Re: hoster

Posted: Tue Nov 28, 2006 5:51 am
by zenny
Jaxolotl wrote:did you check that the server you're parsing the script allows a 5Mb upload from script?
post_max_size and upload_max_filesize on php ini

you can check this by writing a php file with only this code inside
Hi, thanks for the response. i've checked the php.ini file and my server allow upload that is more than 5mb, so is the post_max_size. However, i'm still experiencing problem uploading files to the folder stated.

Posted: Tue Nov 28, 2006 7:35 am
by zenny
I checked the server log this time around and i come across this error msg.. can any1 tell me how i can bypass this with my php script ?

[client 202.156.13.5] PHP Warning: move_uploaded_file(): SAFE MODE Restriction in effect. The script whose uid is 10308 is not allowed to access / owned by uid 0 in /var/www/vhosts/raidsg.net/httpdocs/addonPost.php on line 64, referer: http://www.raidsg.net/addonPost.php

[client 202.156.13.5] PHP Warning: fopen(): open_basedir restriction in effect. File(/addon/3232.txt) is not within the allowed path(s): (/var/www/vhosts/raidsg.net/httpdocs:/tmp) in /var/www/vhosts/raidsg.net/httpdocs/addonPost.php on line 68, referer: http://www.raidsg.net/addonPost.php

[client 202.156.13.5] PHP Warning: fopen(/addon/3232.txt): failed to open stream: Operation not permitted in /var/www/vhosts/raidsg.net/httpdocs/addonPost.php on line 68, referer: http://www.raidsg.net/addonPost.php

[client 202.156.13.5] PHP Warning: fwrite(): supplied argument is not a valid stream resource in /var/www/vhosts/raidsg.net/httpdocs/addonPost.php on line 69, referer: http://www.raidsg.net/addonPost.php

[client 202.156.13.5] PHP Warning: fclose(): supplied argument is not a valid stream resource in /var/www/vhosts/raidsg.net/httpdocs/addonPost.php on line 70, referer: http://www.raidsg.net/addonPost.php

Posted: Tue Nov 28, 2006 8:07 am
by feyd
The file path you are attempting to move it to is /addon. Your host has restricted the paths PHP is allowed to access. I will guess that you actually mean /your/site/root/addon, to which you can often use $_SERVER['DOCUMENT_ROOT'].

Posted: Tue Nov 28, 2006 9:37 am
by zenny
Hi thank you guys for your responses, i have resolved the problem. Most of the problem is of server side permission and some error in my folder structure. I really appreciate the help. =]