0

I am using the following script to upload pictures to my website. It is working perfectly on my local machine. but when I am running on my FTP account with godady it showing me the permission error. I already gave it the 777 permission from my client FTP, but it is still showing me this.

<?php
include ("login.php");
if ($_POST['submit']){


    $name = $_FILES['upload']['name'];
    $temp = $_FILES['upload']['tmp_name'];
    $type = $_FILES['upload']['type'];
    $size = $_FILES['upload']['size'];

    if (($type == "image/jpg") || ($type == "image/png") || ($type == "image/gif") || ($type == "image/jpeg")){
        if  ($size <= 1000000){

                move_uploaded_file($temp,$name);
                echo "<img src='$name'>";
            } else {
                    print"your image file is too big";
                }

        }else {
                print "this file type is not allowed!";
            }


    }else{
            header ("Location: login.php");
        }


?> 

and

<form action="upload.php" method="post" enctype="multipart/form-data">
File: <input type="file" name="upload">
<input type="submit" name="submit" value="Upload!">
</form>

the problem:

Warning: move_uploaded_file(1 (12).jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\Hosting\8923686\html\uploadedimages\upload.php on line 13

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\phpF893.tmp' to '1 (12).jpg' in D:\Hosting\8923686\html\uploadedimages\upload.php on line 13

How do I fix this problem ?

4 Answers 4

1

try to change the folder (Upload to) permission, in your hosting panel, go to Files Manager then find your (Upload to) folder, then find the folder permission icon then allow access to that folder, that works with me !

Sign up to request clarification or add additional context in comments.

Comments

0

Your webserver does not have access to your local drives.

D:\Hosting\8923686\html\uploadedimages\ is invalid

Use relative path which points to your folder, not the direct path

Something like

move_uploaded_file($temp, "uploadedimages/$name");

3 Comments

Do you mean the 'move_uploaded_file($temp,$name); ' path ?
Like this ? move_uploaded_file($temp,"www.mysite.com/uploadedimages/$name");
@user1200640 NO... move_uploaded_file($temp, "uploadedimages/$name");
0

First of all, check the file permissions on the server. Sometimes the file permissions are not set, even if you use a FTP client to fix them.

According to this page I google'd, it seems that Godaddy has changed something regarding FTP Uploads:

http://www.ozzu.com/programming-forum/recent-change-with-godaddy-php-file-uploads-t94040.html

Comments

0

You can try the copy function. http://www.php.net/manual/en/function.copy.php

Example based on your code:

$file_temp = $_FILES["upload"]["tmp_name"];
$file_name = $_FILES["upload"]["name"];

if(!copy($file_temp,"/uploadedimages//$file_name"))
echo "Error on uploading";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.