lyndsey.pearce@ntlworld.com Posted August 1, 2008 Share Posted August 1, 2008 Hi guys, I was hoping someone could help me with a problem? First off, I'll let you know what I have: Local machine is Windows Vista Server is apache - xampp to be precise Developement environment is PHP 5 & MYSQL 5 I have a very simple script that should upload a file to my local server like so: <?php error_reporting(E_ALL); //'submit' button is clicked - submitting all the data if (isset($_POST['submit'])){ //handle file upload //check for the first main image upload if (isset($_FILES['picMain'])){ $filename1 = $_FILES['picMain']['name']; //move the the file from it's temporary location on the server if (move_uploaded_file($filename1, 'C:/xampp/htdocs/web/uploads')){ echo $filename1 . ' has been uploaded!'; }else{ echo $filename1 . ' has not been uploaded!<br /> ERROR: ' . $_FILES['picMain']['error']; } } //insert all data into vehicles, vehiclesmakes, vehiclesmodels, etc.. }else{} ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data" name="form1"> <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> <input type="file" name="picMain" id="picMain" /> <input type="submit" name="submit" id="submit" value="Add" /> </form> </body> </html> What happens is that the script runs, returns the message filename1 has not been uploaded ERROR: 0, and the graphic is not uploaded. I am confused because the Error 0 means there was no error and the file was uploaded. I have double checked the uploads folder path and it is correct. I have found the 'apache' process in windows task manager and the user is 'Lyndsey' - that's me! I have then tried to add permissions to the uploads folder for the user 'Lyndsey' by: Right-clicking the folder Selecting the security tab Finding the user 'Lyndsey' and adding full access (read, write, execute, modify, full control) to that user. Selecting the sharing tab Clicking share Select 'change sharing permissions' Adding 'Lyndsey' userand making that user the owner Clicking 'share'. I also clicked advanced sharing and gave permissions here. I have also looked around this forum for similar threads but found no definitive answers. Anyone any ideas as to what maybe happening? I am new to Vista and XAMPP so still finding my feet. Any help greatly appreciated! Thanks in advance! Lyndsey Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted August 1, 2008 Share Posted August 1, 2008 try turning off UAC Control Panel ==> Classic View ==> User Accounts ==> Turn User Account Control Off ==> restart EDIT: this will turn off all the continue junk and allow you to freely move Quote Link to comment Share on other sites More sharing options...
lyndsey.pearce@ntlworld.com Posted August 1, 2008 Author Share Posted August 1, 2008 cheers, I will give that a whirl! Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted August 1, 2008 Share Posted August 1, 2008 The problem (well, one of them at least) is that you've trying to move $_FILES['picMain']['name'] and not $_FILES['picMain']['tmp_name']; the first parameter of move_uploaded_file should be the temporary name that was automatically given to the file when it was uploaded. See here for the manual page describing a basic upload process. Quote Link to comment Share on other sites More sharing options...
lyndsey.pearce@ntlworld.com Posted August 1, 2008 Author Share Posted August 1, 2008 Hi ronnie88, I tired turning off access control to no avail. GingerRobot, that was a typo on my part. The Files array index I am referencing is $_FILES['picMain']['tmp_name']. I am getting some warnings like: Warning: move_uploaded_file(C:\xampp\htdocs\web\uploads) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\xampp\htdocs\web\upload.php on line 10 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\php50.tmp' to 'C:\xampp\htdocs\web\uploads' in C:\xampp\htdocs\web\upload.php on line 10 C:\xampp\tmp\php50.tmp has not been uploaded! ERROR: 0 Thanks for input so far! Any more ideas? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted August 1, 2008 Share Posted August 1, 2008 I also notice that in your second parameter for move_uploaded_file, you've only specified the directory and not the file name. Quote Link to comment Share on other sites More sharing options...
lyndsey.pearce@ntlworld.com Posted August 1, 2008 Author Share Posted August 1, 2008 Hi GingerRobot, Major screw up on my part. The logic is running now and outputting the message 'tmp_name has been uploaded'. However, there is no sign on the image in the tmp or uploads folders. Permissions? Quote Link to comment Share on other sites More sharing options...
lyndsey.pearce@ntlworld.com Posted August 1, 2008 Author Share Posted August 1, 2008 Got it! C:\xampp\htdocs\web\uploads should be C:\xampp\htdocs\web\uploads\. The image was saving to the root as uploadsimage.gif. Thanks for your help guys! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.