Destination directory can't be created. Can't carry on a process

See all posts Reply

Destination directory can't be created. Can't carry on a process new!
by Luca, 17 years, 10 months ago
Hello,

First of all, I wish to thank you for this php class. Really nice!

Then...
I have a problem in my upload. I'm using a shared hosting and I have chmod and mkdir function blocked.
I use ftp_chmod to change the chmod of the folder where file will be upoaded to 0777 and then I change again the chmod to 0755.

It seems that your script try to create a temp directory and so the process stops with the error "Destination directory can't be created. Can't carry on a process". If this is the problem, is there a way to solve it?

P.S. I update the class to the last verion.

Thank you,

LucaReply
Re: Destination directory can't be created. Can't carry on a process new!
by colin, 17 years, 10 months ago
The class attempts to create a temp file in case of open_basedir restrictions, not a directory. mkdir() will be used only if the destination directory doesn't exist. The destination directory is the argument when you call process().

Create your destination via FTP first, or else try the following:
.....
$handle->process("./");
.....
Reply
Re: Destination directory can't be created. Can't carry on a process new!
by Luca, 17 years, 10 months ago
Nothing... It doesn't work.This is my code:

$folder="/domains/mysite.com/public_html/main/staff/images/pets/"; 
	
if(ftp_chmod($conn_id, 0777, $folder)) {
    
    // we create an instance of the class, giving as argument the PHP object 
    // corresponding to the file field from the form
    // All the uploads are accessible from the PHP object $_FILES
    $handle = new Upload($_FILES['my_field']);

    // then we check if the file has been uploaded properly
    // in its *temporary* location in the server (often, it is /tmp)
    if ($handle->uploaded) {
            
        // yes, the file is on the server
        // below are some example settings which can be used if the uploaded
        // file is an image.
        $handle->file_new_name_body = $_POST["name"];
        $handle->image_resize       = true;
        $handle->image_y        	= 60;
        $handle->image_ratio_x      = 100;
        $handle->image_convert      = 'jpg';
        $handle->jpeg_quality       = 80;
        
        // now, we start the upload 'process'. That is, to copy the uploaded file
        // from its temporary location to the wanted location
        // It could be something like $handle->Process('/home/www/my_uploads/');
        $handle->Process("".$folder."");
            
        // we check if everything went OK
        if ($handle->processed) {
            // everything was fine !
            ftp_chmod($conn_id, 0755, $folder);
            ftp_close($conn_id);
            header("Location: true.php");
            exit;
        } else {
            $errors= $handle->error;
            mail('mymail@mysite.com','errors',$errors); 
            ftp_chmod($conn_id, 0755, $folder);
            ftp_close($conn_id);
            // one error occured
            header("Location: false.php");
            exit;
        }
    }
}

I think the error is in the /tmp directory that I don't have. Is the directory that you talk about in your commented code:

// then we check if the file has been uploaded properly
// in its *temporary* location in the server (often, it is /tmp)

Can you help me?

Thank youReply
Re: Destination directory can't be created. Can't carry on a process new!
by colin, 17 years, 10 months ago
The /tmp directory is set in your php.ini. If you don't have a tmp directory, then you won't be able to upload at all.

The class doesn't try to create the temporary directory. It merely uses it. PHP, for security reason, uploads the file itself into this temp directory, from which is is available to the class (is_uploaded_file() and move_uploaded_file())

I would recommend checking if a simple bit of upload code works, so to make sure that your hosting allows uploads. You can find such code there: http://www.php.net/features.file-uploadReply
Re: Destination directory can't be created. Can't carry on a process new!
by anonymous, 10 years, 7 months ago
Hi,

It was working fine but all of a suddon i get the same error. i have changed nothing in the php files.Reply
Re: Destination directory can't be created. Can't carry on a process new!
by Jack, 16 years, 8 months ago
YOur destination folder path is not valid. Recheck the path to your folder.

Or make it relation, meaning if your upload php file is in public_html/main/staff your folder path should be

$folder = '/images/pets/';Reply
Re: Destination directory can't be created. Can't carry on a process new!
by Dariusz Andryskowski, 12 years, 11 months ago
Probably entered the wrong path on the ftp to the project directory. Try to enter in index.php

echo dirname (dirname (__FILE__));

You will see the path of this type, eg: / home / name_ftp / public_html / your_project /

You can then save to a variable parameter received
$ name_ftp_root = "insert the path directory that appears when you saw the result of an echo";

then you create another parameter telling the directory where you saved your picture
$ folder = '/ images / pets /';
$ tmp_dir_path_photo = $ name_ftp_root. $ folder; // - The path to the root project directory ftp +  path to the directory where the images will zaps

... // Code with support for formatting the uploaded pictures
$ img_photo-> Process ($ tmp_dir_path_photo);
if ($ img_photo-> processed)
{
$ file_photo_name = $ tmp_img_foto-> file_dst_name;
}
else
{
echo 'error:'. $ tmp_img_foto-> error;
}




http://www.poradyseo.pl
http://www.servicemedia.plReply