php move_uploaded_file not working on Windows 7 only - php

I've got a project that I am setting up file uploads for. The project is in Zend, but I am using PHP's $_FILES array and move_uploaded_file to save the files. This was working perfectly on my Windows Vista computer but won't save the file on Windows 7.
It creates a new folder for every upload no problem, but won't save the file and gives no error message. It is the same exact code as the other computer (grabbed from source control) and both are using PHP 5 with WAMP server. Any ideas why the Windows 7 computer won't save? I even added Full Control to 'Everyone' for the uploads folders.

In Windows 7:
Go to this location -> C:\Windows\Temp
Windows will ask permission- > press go or confirm or yes
then try again to upload files
finish

if your saving the files in the system drive, you might have a problem due to its security.. try to transfer your WAMP and PHP in other local drives. but if you insist to have it in your system file. just try to work around with its security.. Good Luck!

When you create the folder you want to move it to, are you setting the permissions in php? When I switched to windows 7 I had the same problem and setting the permissions solved it for me.
mkdir("/path/to/your/dir", 0777);

I read that chmod is ignore by windows on the php.net > mode reference. I was not able to mkdir on windows 7 by using mkdir /path/to/directory or path\to\directory\. I also tried editing the permissions for the parent (root?) directory I was using for the new folder. No solutions found here, yet. The folder reverts to read-only after unchecking the box on the folder settings though so maybe that is part of it

Related

Missing Temporary Folder in WordPress (PHP 5.6) on IIS, Windows Server 2012 R2

I am helping out with a WordPress site which is hosted on IIS on Windows Server 2012 R2, running PHP 5.6
(don't ask - and please don't snark - this is a website for my local church)
For some reason I keep getting "Missing Temporary Folder" everytime someone tries to upload any media files.
I have tried creating a "temp" folder in the "wp-content" folder.
I have also reset all permissions on the ENTIRE wp-content folder, removing any "read-only" locks and granting all users "full control" (yes - I'm getting this desperate to just get the dang thing working at this point!)
In the wp-config.php I've specified my temp directory.
(this used to be a relative path, but I've switched to an absolute path, just to rule out the virtual directory in IIS confusing things)
define('WP_TEMP_DIR', 'C:\inetpub\wwwroot\wp_church\wp-content\temp');
In my PHP.ini (in the installation folder for PHP) I defined:
upload_tmp_dir = C:\wpupload
I created that folder, and again gave all users full control.
I have since rebooted the server and run IISRESET numerous times.
But every time I try uploading a media file I still get the error message:
Missing Temporary Folder
Can anyone help???
Please?
Ok sorry about this.
it would appear that "upload_tmp_dir" is declared TWICE in the php.ini file.
I found another one right at the very bottom. I changed that .. all fixed!!

Images on PHP pages on Linux OS disappears

I'm trying to display image on my PHP pages, but Google Chrome and Firefox on Ubuntu refuse to display the images. The same pages with the same images run pretty well in both browsers using Windows. Can any one explain to me what is happening ?
check to directory where your images are stored, make sure the permission is set to 777, or 775,
on your ubuntu terminal,
type in:
sudo chmod 777 /images_dir -R
There are 1001 reasons that could cause this.
Most probable ones:
Case problems on the file names. Many people developing systems in Windows and then porting in Linux face this problem. Remember that Linux is case sensitive. A file name a.png is different from A.png. On the other hand, windows is not case sensitive.
Permission. Your files could have a permission problem. Try to open the files from the same directory the browser is trying to retrieve the files from. If you have problems in doing this, then Firefox will have the same problem (since it runs with your credentials).

PHP can't open uploaded files

I have Ubuntu Server with lamp.
When i uploading files like xls or images it works fine, but when I trying to open it says me that the Excel file was broken. Same thing happens with images
Is it possible that php changes the file?
Permissions for /var/www/publick_html/uploads is 777
well, I know,I use windows and maybe this is extremely OFF TOPIC, but I have a simililar problem with uploaded files and my experience can be usefull for other people.
In my case, the uploaded file can not be open because it was written first in
C:\Windows\Temp
and then moved to the upload directory, but my temp folder doesn t have permission to access to it. Infact, if I click on temp folder I see:
After I clicked "Continue", the problem has been solved!
The problem was in versions of apache and php.
Version of apache was 2.2 and php was 5.4
I upgraded my apache to 2.4 version and now it works fine.
This should solve your problem with being unable to open uploaded files with PHP on SQL SERVER. It solved mine.
You may come across the following problem using PHP on Microsoft IIS: getting permission denied errors from the move_uploaded_file function even when all the folder permissions seem correct. I had to set the following to get it to work:
Write permissions on the the folder through the IIS management console.
Write permissions to IUSR_'server' in the folder's security settings.
Write permissions to "Domain Users" in the folder's security settings.
The third setting was required because my application itself lives in a secure folder - using authentication (either Basic or Windows Integrated) to identify the users. When the uploads happen IIS seems to be checking that these users have write access to the folder, not just whether the web server (IUSR_'server') has access.
Also, remember to set "Execute Permissions" to "None" in the IIS management console, so that people can't upload a script file and then run it. (Other checks of the uploaded file are recommended as well but 'Execute None' is a good start.)
reference https://www.php.net/manual/en/features.file-upload.php

Write access not permitted in Windows 7 for CakePHP app

I primarily use Mac OSX for programming and then test it in windows periodically. I just installed XAMPP on a Windows 7 computer and I'm getting the following errors
Warning: _cake_core_cache was unable to write 'cake_dev_en-us' to File cache in C:\Program Files\xampp\htdocs\testproj\lib\Cake\Cache\Cache.php
Warning: C:\Program Files\xampp\htdocs\testproj\lib\Cake\Cache\persistent is not writable in C:\Program Files\xampp\htdocs\testproj\lib\Cake\Cache\Engine\FileEngine.php
I opened up the testproj folder properties and unchecked Read Only and applied it to all folders/subfolders. I tried to open the Cake application again and the same error message was displaying so I checked the folder properties again and it had a square in the Read-Only box, not a check mark. Does that signify anything? I'm not sure what exactly the square means instead of a check mark.
I am signed into the administrator account on this computer. Is there some kind of command similar to chmod -R 777 for windows?
Thanks
Update - I changed the installation from Program Files to C:\xampp... and I still get the errors. I then created a partition and installed xampp to G:\xampp... and the error still exists
Using C:\ and especially the Program Files folder is a really bad idea for developing with PHP on Windows. Use another partition or at least a folder outside of system internal folders.
There is a reason WAMP and most tools by default try to install themselves in C:\wamp\ etc.
Edit: also try to avoid folder names with spaces in them like the windows-stupid "Program Files" default folder. And mind your casing, even if that is not directly visible in Windows, it will otherwise kill your app when going live with it on a unix server.

file_exists() not working on AWS ec2 server, even though works on dev server and file is where it is

I have a buddypress installation on an Amazon ec2 server running default Debian linux, wordpress and buddypress installed. Users are trying to upload avatars, but they cannot be resized. This is because in the buddypress code for resizing avatars, a call to file_exists($original_file) returns false, even though I can see that the file is in exactly the directory where it's supposed to be.
This is not a problem on our development server, where uploading avatars works flawlessly. The next line of code is what causes the resizing to fail.
$original_file = '/var/www/html/wp-content/uploads/avatars/1/test-picture.png';
if(!file_exists($original_file)
return false;
Now I am ssh'd in that directory, and can see that that path is absolutely correct. I am guessing this is an issue with php permissions? To be able to access that directory and see that the file doe sin fact exist.
All files are now owned by apache:apache. I've experimented with chmod 775 and 777, but still php cannot recognize the file. Does anybody know how php can be configured on this Amazon ec2 server so that it can recognize that the file does in fact exist?
If you pasted your code above correctly, you will get a syntax error that will show up in your syslog that you are missing a closing ) in your if statement.
Your code should look like this:
$original_file = '/var/www/html/wp-content/uploads/avatars/1/test-picture.png';
if(!file_exists($original_file))
return false;
One possible cause could be case sensitivity. You state that your production server runs linux, which IS case sensitive. If your development server is a mac, you are most likely working with a non-case sensitive filesystem.
Possible solution: safe all images in all-lower-case and user lowercase directories. When calling file_exists, call strtolower on the file name.
If you are developing on a windows machine, you might be using \ as directory separators.
Possible solution:
Always use / as directory separators, since that will work on all systems.
Do you have these issues when saving to a folder that is above your document root?

Categories