Jump to content

help with this code...


almightyegg

Recommended Posts

this is my upload script:
[code=php:0]
<?
if(!$step){
?>
<form enctype="multipart/form-data" name="form1" method="post" action="uploadweb.php?step=change">
<input type="file" name="uploadedfile">
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
<input type="submit" name="Submit" value="Upload Image" />
</p>
</form><br>
<?
}elseif($step=="change"){

$target = "http://www.lordoftheabyss.com/images/players/$mem[id]/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else {
echo "Sorry, there was a problem uploading your file.";
}

}
?>
[/code]
i browse for the file and click upload and then it says 'Sorry, there was a problem uploading your file.' and i have no idea why...i cant spot anything wrong  ???
Link to comment
Share on other sites

the page the uploader is on is:
url.com/account/uploader.php
and the directories to upload to is
url.com/images/player/playerid
so it doesnt recognise the path???
[code=php:0]
$target = $_SERVER['DOCUMENT_ROOT'] . "/images/players/$mem[id]";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if ($uploaded_size > 350000)
{
echo "Your file is too large.<br>";
$ok=0;
}

//This is our limit file type condition
if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}

//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}

//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
[/code]
Link to comment
Share on other sites

still says it couldnt upload my file  :(
[code=php:0]
<?
if(!$step){
?>
<form enctype="multipart/form-data" name="form1" method="post" action="uploadweb.php?step=change">
<input type="file" name="uploadedfile">
<input type="submit" name="Submit" value="Upload Image" />
</p>
</form><br>
<?
}elseif($step=="change"){

$target = "../images/players/$mem[id]";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if ($uploaded_size > 350000)
{
echo "Your file is too large.<br>";
$ok=0;
}

if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}

if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}

//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
}
?>
[/code]
Link to comment
Share on other sites

[code=php:0]
if(!$step){
?>
<form enctype="multipart/form-data" name="form1" method="post" action="uploadweb.php?step=change">
<input type="file" name="uploadedfile">
<input type="submit" name="Submit" value="Upload Image" />
</p>
</form><br>
<?
}elseif($step=="change"){

$target = "../images/players/$mem[id]";
$target = $target . basename( $_FILES['uploaded']['name']) ;  //line 104
$ok=1;
if ($uploaded_size > 350000) //line 106
{
echo "Your file is too large.<br>";
$ok=0;
}

if ($uploaded_type =="text/php")  //line 112
{
echo "No PHP files<br>";
$ok=0;
}

if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}


else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) //line 126
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
}
?>
[/code]

Notice: Undefined index: uploaded in /home/lordofth/public_html/account/uploadweb.php on line 104

Notice: Undefined variable: uploaded_size in /home/lordofth/public_html/account/uploadweb.php on line 106

Notice: Undefined variable: uploaded_type in /home/lordofth/public_html/account/uploadweb.php on line 112

Notice: Undefined index: uploaded in /home/lordofth/public_html/account/uploadweb.php on line 126
Link to comment
Share on other sites

Warning: move_uploaded_file(../images/players/1/plasma.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/lordofth/public_html/account/uploadweb.php on line 126

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpmKpwOX' to '../images/players/1/plasma.jpg' in /home/lordofth/public_html/account/uploadweb.php on line 126
Sorry, there was a problem uploading your file.
is that a CHMOD thing?
Link to comment
Share on other sites

yeah....

try setting the players directory to 0774
or 0775 if that doesn't work

I'm not a permissions expert but that should work

If your wondering how to change the permissions
you can either make a temporary php file that says this

if(chmod("../images/", 0774)
echo "success";
else
echo "failed";

or change it in the File Manager or Explorer....depending on what OS your using
Link to comment
Share on other sites

o wait i was reading a different chmod problem (which is now fixed) so this one isnt fixed :(
errors-
Warning: move_uploaded_file(../images/players/1/plasma.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/lordofth/public_html/account/uploadweb.php on line 125

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phphgU6A2' to '../images/players/1/plasma.jpg' in /home/lordofth/public_html/account/uploadweb.php on line 125
Sorry, there was a problem uploading your file.
[code]
<?
if(!$step){
?>
<form enctype="multipart/form-data" name="form1" method="post" action="uploadweb.php?step=change">
<input type="file" name="uploadedfile">
<input type="submit" name="Submit" value="Upload Image" />
</p>
</form><br>
<?
}elseif($step=="change"){

$target = "../images/players/$mem[id]/";
$target = $target . basename( $_FILES['uploadedfile']['name']) ;
$ok=1;
if ($uploadedfile_size > 350000)
{
echo "Your file is too large.<br>";
$ok=0;
}

if ($uploadedfile_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}

if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}


else
{
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
}
?>
[/code]
Link to comment
Share on other sites

ooh wait...it now uploads to url/images/players/1 but not url/images/players/21
maybe because file one has CHMOD 777 and file 21 has CHMOD 755 but it wont let me change file 21 for some reason...

so my next question is how do you mkdir() and chmod the file hen makiing it?
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.