millercj Posted June 17, 2012 Share Posted June 17, 2012 Trying to write a basic php file upload script and am getting: Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpI0JnBe' to 'http://www.domain.com/up/filename.jpg' in /home/domain/public_html/up/uploadFile.php on line 14 This is my code, I'd assume it is a permissions issue but not sure how to fix that. Any help would be great... <?PHP echo "<table border=\"1\">"; echo "<tr><td>Client Filename: </td> <td>" . $_FILES["fileToUpload"]["name"] . "</td></tr>"; echo "<tr><td>File Type: </td> <td>" . $_FILES["fileToUpload"]["type"] . "</td></tr>"; echo "<tr><td>File Size: </td> <td>" . ($_FILES["fileToUpload"]["size"] / 1024) . " Kb</td></tr>"; echo "<tr><td>Name of Temporary File: </td> <td>" . $_FILES["fileToUpload"]["tmp_name"] . "</td></tr>"; echo "</table>"; move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], "http://www.domain.com/up/" . $_FILES["fileToUpload"]["name"]); ?> Link to comment https://forums.phpfreaks.com/topic/264351-basic-file-upload/ Share on other sites More sharing options...
kicken Posted June 17, 2012 Share Posted June 17, 2012 You can't use a URL as the target location to move a file too. You have to use a file system path. Most likely you will want to use: $_SERVER['DOCUMENT_ROOT'].'/up/'. $_FILES["fileToUpload"]["name"]; As your target location to move the file too. $_SERVER['DOCUMENT_ROOT'] will give you the file system path that corresponds to your domain's directory. Then you add on the sub path of up/ and the filename. Link to comment https://forums.phpfreaks.com/topic/264351-basic-file-upload/#findComment-1354706 Share on other sites More sharing options...
millercj Posted June 17, 2012 Author Share Posted June 17, 2012 That was it...thanks Link to comment https://forums.phpfreaks.com/topic/264351-basic-file-upload/#findComment-1354714 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.