hi! i'm new in php and I'd like to know what's the correct code for adding a file into a directory. The file is from a form and you have to select a directory in the form where to add it. I used this code:
$uploadDir = '../site/photos/'$_POST['albums']'';
if(isset($_POST['submit']))
{
$fileName = $_FILES['image1']['name'];
$tmpName = $_FILES['image1']['tmp_name'];
$fileSize = $_FILES['image1']['size'];
$fileType = $_FILES['image1']['type'];
$filePath = $uploadDir.$fileName;
$result = move_uploaded_file($tmpName, $filePath);
but it's not working.
Thanks!
uploading file into a directory
Moderator: General Moderators
-
agent007marc
- Forum Newbie
- Posts: 3
- Joined: Tue Sep 08, 2009 11:37 pm
Re: uploading file into a directory
Are you sure the directory is "writable"? On *nix systems this means either making the directory owned or a part of the user group that the web server daemon runs as, or simply using CHMOD 0777 on the folder (though, I'd argue that this is less secure, but you don't have much of a choice if you are on shared hosting).
Perhaps you should display errors so you can get any output from PHP.
Perhaps you should display errors so you can get any output from PHP.
-
agent007marc
- Forum Newbie
- Posts: 3
- Joined: Tue Sep 08, 2009 11:37 pm
Re: uploading file into a directory
I got it already. Thanks!