•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,574 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,597 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 842 | Replies: 8
![]() |
•
•
Join Date: Oct 2007
Posts: 10
Reputation:
Rep Power: 2
Solved Threads: 0
Hi i'm trying to upload a picture to the server using a form and it all seems to be working fine the only problem is I can't seem to find the picture when its uploaded, the script runs fine and gives me no errors and then when I come to look in the folder where i think it should be, there is nothing there. I'm using a test environment on the mac and am using the inbuilt apache server on OSX but don't have any idea which is the root folder as far as the move_uploaded_file function is concerned:
$destination = "upload/";
move_uploaded_file($_FILES["pix"]["tmp_name"], $destination.$_FILES["pix"]["name"]);
echo "br />Moved to: " .$destination.$_FILES["pix"]["name"];
This is the offending code, now I would assume that the file would be in a folder called upload on the mac HD, anyone know where i'm going wrong!?
Cheers.
$destination = "upload/";
move_uploaded_file($_FILES["pix"]["tmp_name"], $destination.$_FILES["pix"]["name"]);
echo "br />Moved to: " .$destination.$_FILES["pix"]["name"];
This is the offending code, now I would assume that the file would be in a folder called upload on the mac HD, anyone know where i'm going wrong!?
Cheers.
use the actual path /path/to/your/html/upload
Need a simple, powerful knowledgebase? Bigattichouse Knowledge Base finds the solution while you're still typing the problem.
http://www.bigattichouse.com/knowledgebase.html
http://www.bigattichouse.com/knowledgebase.html
•
•
Join Date: Oct 2007
Posts: 10
Reputation:
Rep Power: 2
Solved Threads: 0
Right am thoroughly tearing my hair out on this one, thanks to you guys so far for your help, but I have a feeling there is something else happening apart from my inability to work out addressing properly, heres the full code,
$destination = '/upload/'.$_FILES["pix"]["name"];
echo $_FILES["pix"]["tmp_name"];
if(move_uploaded_file($_FILES['pix']['tmp_name'], $destination))
{
echo "br />Moved to: ".$destination;
}
else
{
echo "Not working fool".$destination;
}
I am using apache and php 5 on localhost, that is they are installed on my mac and i'm running the upload program through the webserver folder. I have created a folder on the mac HD called 'upload' but can't get the thing to work...any ideas.
$destination = '/upload/'.$_FILES["pix"]["name"];
echo $_FILES["pix"]["tmp_name"];
if(move_uploaded_file($_FILES['pix']['tmp_name'], $destination))
{
echo "br />Moved to: ".$destination;
}
else
{
echo "Not working fool".$destination;
}
I am using apache and php 5 on localhost, that is they are installed on my mac and i'm running the upload program through the webserver folder. I have created a folder on the mac HD called 'upload' but can't get the thing to work...any ideas.
•
•
Join Date: Aug 2005
Location: somewhere in time
Posts: 81
Reputation:
Rep Power: 4
Solved Threads: 5
I think what people are trying to tell you is that you need to replace,
$destination = "upload/";
with
$destination = $_SERVER['DOCUMENT_ROOT']."/upload/";
That should fully specify your local path to the destimation directory.
You may also be running into problems trying to to this on a Mac. It might not work the same as on a Unix/Linux server.
$destination = "upload/";
with
$destination = $_SERVER['DOCUMENT_ROOT']."/upload/";
That should fully specify your local path to the destimation directory.
You may also be running into problems trying to to this on a Mac. It might not work the same as on a Unix/Linux server.
•
•
Join Date: Aug 2005
Location: somewhere in time
Posts: 81
Reputation:
Rep Power: 4
Solved Threads: 5
It's usually a good idea to add the following to the top of any PHP script that you are troubleshooting.
error_reporting(E_ALL);
You would have seen the permissions issue right away.
But it is not a good idea to leave that statement active on a script on a production site.
error_reporting(E_ALL);
You would have seen the permissions issue right away.
But it is not a good idea to leave that statement active on a script on a production site.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- File Upload Help (PHP)
- File upload problem (PHP)
- Need file upload code for word Doc (HTML and CSS)
Other Threads in the PHP Forum
- Previous Thread: MySQL update not working
- Next Thread: Lyrics Script - Help me creating a submit.php to sumbit new lyrics


Linear Mode