2 Replies - 714 Views - Last Post: 23 May 2012 - 03:37 AM Rate Topic: -----

#1 ryderx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-March 10

cant upload files to my server please help

Posted 23 May 2012 - 02:23 AM

this is my script it keep showing me the next error and i dont know what i have to change to make it work.

I really need some help thank you in advance.

Warning: move_uploaded_file(memberFiles/1/pic1.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/cemediad/public_html/School/edit_pic.php on line 29

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpb9cMHq' to 'memberFiles/1/pic1.jpg' in /home/cemediad/public_html/School/edit_pic.php on line 29


<?php
session_start(); 

if (!isset($_SESSION['id'])) { 
   echo 'Please <a href="login.php">log in</a> to access your account';
  exit(); 
} 

$id = $_SESSION['id'];
echo $id;
if ($_FILES['uploadedfile']['tmp_name'] != "") {
    $maxfilesize = 120000;
    if($_FILES['uploadedfile']['size'] > $maxfilesize ) { 
        echo "<br /><br />Your image was too large. Must be 100kb or less, please<br /><br />
        <a href=\"edit_pic.php\">click here</a> to try again";
        unlink($_FILES['uploadedfile']['tmp_name']); 
        exit();

    } else if (!preg_match("/\.(gif|jpg)$/i", $_FILES['uploadedfile']['name'] ) ) {
        echo "<br /><br />Your image was not .gif or .jpg and it must be one of those two formats, please<br />
        <a href=\"edit_pic.php\">click here</a> to try again";
        unlink($_FILES['uploadedfile']['tmp_name']);
        exit();

    } else { 

        $newname = "pic1.jpg";

        if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], "memberFiles/$id/".$newname)) {
            echo "Success, the image has been uploaded and will display to visitors!<br /><br />
            <a href=\"member_account.php\">Click here</a> to return to your profile edit area";
            exit();
        } else {
            echo "There was an error uploading the file, please try again. If it continually fails, contact us by <a href= mambocinco@gmail.com>email.</a>. <br /><br />
            <a href=\"member_account.php\">Click here</a> to return to your profile edit area";
            exit();
        }
    } 
} 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Edit Your Account Info</title>
<script type="text/javascript">
<!-- Form Validation -->
function validate_form ( ) { 
valid = true; 
if ( document.form.uploadedfile.value == "" ) { 
alert ( "Please browse for a file on your PC and place it" ); 
valid = false;
}
return valid;
}
<!-- Form Validation -->
</script>
</head>
<body>
     <div align="center">
       <h3><br />
         <br />
       Upload or replace your profile image here <br />  
       <br />
       </h3>
     </div>
     <table border="2" align="center" cellpadding="5" cellspacing="5">
      <form action="../School/edit_pic.php" method="post" enctype="multipart/form-data" name="form" id="form" onsubmit="return validate_form ( );">
         <tr>
           <td colspan="2"><img src="memberFiles/<?php echo "$id"; ?>/pic1.jpg" alt="Ad" width="150" /></td>
         </tr>
		 <tr>
           <td colspan="2"><input name="uploadedfile" type="file" /></td>
         </tr>
         <tr>
           <td colspan="2"><div align="center">
             <input type="submit" name="Submit" value="Upload Image" />
           </div></td>
         </tr>
       </form>
</table>
</body>
</html>


MOD EDIT: Added code tags. When posting code...USE CODE TAGS!!!

:code:

This post has been edited by JackOfAllTrades: 23 May 2012 - 02:43 AM


Is This A Good Question/Topic? 0
  • +

Replies To: cant upload files to my server please help

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6106
  • View blog
  • Posts: 23,653
  • Joined: 23-August 08

Re: cant upload files to my server please help

Posted 23 May 2012 - 02:44 AM

Quote

No such file or directory

Does the file /tmp/phpb9cMHq exist?
Does the directory memberFiles/1 exist?
Was This Post Helpful? 0
  • +
  • -

#3 ryderx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-March 10

Re: cant upload files to my server please help

Posted 23 May 2012 - 03:37 AM

View PostJackOfAllTrades, on 23 May 2012 - 02:44 AM, said:

Quote

No such file or directory

Does the file /tmp/phpb9cMHq exist?
Does the directory memberFiles/1 exist?


The directory memberFiles/1 does exist but wen ever i try to look up the /tmp directory its not under the main path to rest of the documents so i want to know how can i change it to make it uplode into the directory [il]memberFiles/1?
thank you for the reply
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1