Question

For this I'm using:

  • redactor -> wysiwyg
  • upload.php -> file that modifies image name and uploads

I'm using redactor to allow people to chat on my site. the imageUpload is pointing to a upload.php file correctly that contains the following code:

// files storage folder
$dir = '/image/upload/';

$_FILES['file']['type'] = strtolower($_FILES['file']['type']);

if ($_FILES['file']['type'] == 'image/png'
|| $_FILES['file']['type'] == 'image/jpg'
|| $_FILES['file']['type'] == 'image/gif'
|| $_FILES['file']['type'] == 'image/jpeg'
|| $_FILES['file']['type'] == 'image/pjpeg')
{
    // setting file's mysterious name
    $file = $dir.md5(date('YmdHis')).'.jpg';
    // copying
    move_uploaded_file($_FILES['file']['tmp_name'], $file);

    // displaying file
    $array = array(
        'filelink' => $file
    );

    echo stripslashes(json_encode($array));
}

The ajax is throwing a broken image in the wysiwyg that points to the right folder location and the modified file name correctly. The file itself is not actually getting uploaded

I've set the folder permissions to 775 with the following:

chmod -R 775 /foo/image
chmod -R 775 /foo/image/upload

I'm still having no luck on the image actually uploading. Is something wrong with my code? Maybe my permissions weren't set correctly?

UPDATE:

With the absolute path it wants to work but its telling me its a permissions problem now. Am I setting the wrong permissions or am I not setting the permissions to the right areas?

Was it helpful?

Solution

I think your path is still incorrect, /image/ is trying to go to the root of your filesystem if im correct. Try adding the complete filesytem path before /image/ for example C:\websites\website\image\ etc..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top