Page 1 of 1

PHP $upload_dir Error!!!!!

Posted: Thu Oct 26, 2006 3:20 pm
by zain1992
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi. My name is Zain. I am having problem with this PHP code i recently used. this code is supposed to upload a file and put it in a directory in the server. Now i want to upload this fil from the server my PHP file is on and upload it to another server or save it in another server. here is the code:

Code: Select all

<?php
//edit this
$_max_file_size = '9999999999'; //file size in bytes.
$upload_dir = "Gallery/"; //upload folder..chmod to 777
$_i = "8";                //number of files to upload at one time
//end edit 

echo "Maximum file size : " . $_max_file_size/1000 . "KB<br>";
echo "<form enctype='multipart/form-data' action='?do=upload' method='post'>";
echo "<input type='hidden' name='MAX_FILE_SIZE' value='" . $_max_file_size , "'>";
echo "Choose your file(s): <br>";
//show number of files to select
For($i=0; $i <= $_i-1;$i++) 
{
echo "<input name='file" . $i . "' type='file'><br>";
}
echo "<input type='submit' value='Upload File'>";
echo "</form>";

if($_GET['do'] == 'upload')
{
//upload all the fields until done
For($i=0; $i <= $_i-1; $i++) 
{
//create a random number
$_random = rand(1, 1000000);
//file with the upload folder
$target_path = $upload_dir . $_random . basename($_FILES['file' . $i]['name']);
//actual file name with the random number
$_file_name = $_random . basename($_FILES['file' . $i]['name']);

//do not upload the 'left blank' fields
if(basename($_FILES['file' . $i]['name']) != '')
{

if(move_uploaded_file($_FILES['file' . $i]['tmp_name'], $target_path)) 
{
     //uploaded successfuly
    $_uploaded=1;
} 
else
{
    //error uploading
    $_error=1;
}
}
else
{
$_check=$_check+1;
}
	
}

//file(s) did upload
if($_uploaded == '1')
{
$_uploaded=0;
echo "The file(s) have been uploaded.<br>";
}
//file uploaded?
if($_error == '1')
{
$_error=0;
echo "There was an error uploading some of the file(s), please try again! Maybe the file size. Maximum file size is " . $_max_file_size/1000 . "KB<br>";
}
//user selected a file?
if($_check == $_i)
{
$_check=0;
echo "Select a file first than click 'Upload File'<br>";
}
}
?>

Also here is an Illustration of what i need to do:
Image


So if some one can please help me with htis it would be great.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Oct 26, 2006 5:32 pm
by kday
Did you make sure the permissions of the folder is set to 0777?

Posted: Thu Oct 26, 2006 10:08 pm
by zain1992
yes

Posted: Thu Oct 26, 2006 10:53 pm
by zain1992
PLEAS CAN SOME ONE HELP ME?

Posted: Thu Oct 26, 2006 11:00 pm
by Zoxive
zain1992 wrote:PLEAS CAN SOME ONE HELP ME?
OMG HELP HELP HELP!!!!!!!!

and "PHP $upload_dir Error!!!!!" has nothing to do with your problem its your user error....

I'm pretty sure you need to have a full path to your $upload_dir.....

Code: Select all

$upload_dir = "/home/user/public_html/Gallery/"; //upload folder..chmod to 777
-NSF

Posted: Thu Oct 26, 2006 11:24 pm
by zain1992
Yes i have tried that. i put "http://myserver.com/www/folder" but it says http wrapper error or something like that.

Posted: Thu Oct 26, 2006 11:31 pm
by Zoxive
zain1992 wrote:Yes i have tried that. i put "http://myserver.com/www/folder" but it says http wrapper error or something like that.
Absolute path. that means no http://

still stumped?

try

Code: Select all

print realpath(dirname(__FILE__));
and work from there....

-NSF

Posted: Thu Oct 26, 2006 11:48 pm
by zain1992
hi and thanks for helpin me with this problem but i dont know where to place that piece of code. can you please edit the PHP file and then post it. thanlks

Posted: Fri Oct 27, 2006 11:21 am
by RobertGonzalez
zain1992 wrote:hi and thanks for helpin me with this problem but i dont know where to place that piece of code. can you please edit the PHP file and then post it. thanlks
I bet if you offered him payment for doing your work for you, he would. Please don't take this the wrong way, but we are not here to write your code for you. We are here to help you learn how to develop in PHP... on your own. Try first, then ask for help. If you want someone to do it for you, offer him a contract.

Posted: Fri Oct 27, 2006 1:11 pm
by Zoxive
Everah wrote:
zain1992 wrote:hi and thanks for helpin me with this problem but i dont know where to place that piece of code. can you please edit the PHP file and then post it. thanlks
I bet if you offered him payment for doing your work for you, he would. Please don't take this the wrong way, but we are not here to write your code for you. We are here to help you learn how to develop in PHP... on your own. Try first, then ask for help. If you want someone to do it for you, offer him a contract.
Haha, thanks for saying that. It's true.

This website is here for others to help others, in the community, not for people to sign up, and do free work for them, its all a learning experience.

We do our best to point you guys in the right direction, without doing all the work.

-NSF

Posted: Fri Oct 27, 2006 7:18 pm
by zain1992
I did try to do it my self. But i have no idea how to do it. if i did i wouldnt be asking you. Thank you every body for help. i am moving to another forum!

Posted: Sat Oct 28, 2006 9:31 am
by RobertGonzalez
Sorry to see you go zain1992.