Jump to content

image upload issue on MAMP Pro for Windows


ctrick
 Share

Recommended Posts

Hi there,

i am using MAMP Pro for Windows as dev-environment. Installation of PW went fine but I have an issue with image uploading:

error.jpg

I have tested if the Dir is writable with this script - there are no problems..

<?php
$myfile = fopen("C:\\Windows\\temp\\testfile.txt", "w") or die("Unable to write file!");
$txt = "Test Text\n";
fwrite($myfile, $txt);
fclose($myfile);
echo "File saved ok.";
?> 

Any ideas?

Thanks!

Chris

Link to comment
Share on other sites

Modified script works, too.

<?php
$myfile = fopen('C:\Windows\temp\testfile.txt', "w") or die("Unable to write file!");
$txt = "Test Text\n";
fwrite($myfile, $txt);
fclose($myfile);
echo "File saved ok.";
?> 
Link to comment
Share on other sites

The default MAMP document root (at least for MAMP) is "C:\mamp\htdocs" unless you have changed it in the preferences.  That is where your HTML/PHP and image files are stored.

The MAMP Pro docs talk about being installed in /Applications/Mamp (how that actually works in Windows is not defined or detailed anywhere I could see).

Unfortunately, the MAMP PRO documentation is very Mac specific and it does not talk much about the configuration differences on the Windows version.  It's very hard to help you with this when the MAMP PRO docs aren't very helpful.

You may also want to ensure that you are using the latest version (3.0.9 Release Candidate 1).

You obviously have MAMP Pro working, so the next question would be where is your document root pointed to?

  • Like 1
Link to comment
Share on other sites

I have installed the latest version of MAMP (3.0.9 Release Candidate 1) with default settings.

In the hosts-panel I created a .dev host with default PHP version (5.6.8):

mamp1.jpg

Is there any way to fix this issue by editing the PW config? In XAMPP for windows PW runs without problems, but i like the way MAMP manages the hosts.

Thanks!

Link to comment
Share on other sites

Hi,

the error in your first screen advices you to define $config->uploadTmpDir (in site/config.php) and ensure that it is writeable.

So, I don't know MAMP and how it manages things, but I would simply try to find a place for uploads by try and error if there are no useful docs for Windows.

For example you can try to create C:\MAMP\htdocs\tmp, and set this in your site/config.php

$config->uploadTmpDir = 'c:/mamp/htdocs/tmp/';  // yes, you can use forward slashes, PHP and Apache on Windows converts this internally where needed, also try with trailing slash first!

And if this doesn't work, go to that folder with the windows explorer and set it rigths to writeable for everyone as a quick and dirty test. Than try again. If this doesn't help come back here and tell us.

(missing trailing slash for the directory ?)

You may also try

$config->uploadTmpDir = 'c:/windows/tmp/'; // traing slash !!
Edited by horst
  • Like 2
Link to comment
Share on other sites

This is the sequence of code that gets executed before that error:

$dir = wire('config')->uploadTmpDir;if(!$dir || !is_writable($dir)) $dir = ini_get('upload_tmp_dir');
if(!$dir || !is_writable($dir)) $dir = sys_get_temp_dir();
if(!$dir || !is_writable($dir)) throw new WireException("Error writing to $dir. Please define \$config->uploadTmpDir and ensure it is writable."); 
I don't think the trailing slash matters here, unless that causes Windows to return the wrong permissions for the directory (?). My best guess is that the values returned by both your PHP upload_tmp_dir and sys_get_temp_dir() are not writable or don't exist. Manually specifying the $config->uploadTmpDir would be the best course of action here. 
  • Like 2
Link to comment
Share on other sites

  • 2 months later...

Hi there,

i am using MAMP Pro for Windows as dev-environment. Installation of PW went fine but I have an issue with image uploading:

error.jpg

I have tested if the Dir is writable with this script - there are no problems..

Any ideas?

Thanks!

Chris

Please try the latest MAMP PRO 3.1.0 from download site: https://www.mamp.info/en/downloads/

Newer version works under System account so access to C:\Windows\temp\ is available.

Previous versions used Network Service account and access to C:\Windows\temp\ was forbidden.

Edited by netomc
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...