aebstract Posted March 12, 2007 Author Share Posted March 12, 2007 I don't think YOU know what YOU are talking about. I came here with the code already, trying to get it to work. You gave me basically the same code, still not working. So what do you mean by asking me if I have ever tryed to finish it by myself, of course I have. ( before I came to the forums I tryed to write it out and make it work ) That is the reason I am here, I couldn't get it to work on my own. I thought that was obvious and the point of help forums. If anyone else can help further, that would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/42354-solved-upload-form/page/2/#findComment-205646 Share on other sites More sharing options...
monk.e.boy Posted March 13, 2007 Share Posted March 13, 2007 Okay I tryed: if (move_uploaded_file ($FILES['thefile']['tmp_name'], "/httpdocs/uploads/{$_FILES['thefile']['name']}")) { and if (move_uploaded_file ($FILES['thefile']['tmp_name'], "hillmarketinggroup.com/httpdocs/uploads/{$_FILES['thefile']['name']}")) { and if (move_uploaded_file ($FILES['thefile']['tmp_name'], "hillmarketinggroup.com/uploads/{$_FILES['thefile']['name']}")) { none are doing anything, just basically brings me back to the form. What I don't get is why it isn't telling me the reason it isn't uploading. Is there any code I can add on to that line to see if there are any errors coming out of it? Please please please try the FULL path. From the root dir: /var/www/html/uploads/ or whatever your FULL PATH is. This is 90% probably your error. Or try: $_SERVER['DOCUMENT_ROOT']. '/uploads/' as the path. monk.e.boy Link to comment https://forums.phpfreaks.com/topic/42354-solved-upload-form/page/2/#findComment-206077 Share on other sites More sharing options...
aebstract Posted March 13, 2007 Author Share Posted March 13, 2007 see I thought I tryed the full path, I'm not 100% sure on what it is I tryed the following: if (move_uploaded_file($_FILES['thefile']['tmp_name'], "$_SERVER['DOCUMENT_ROOT']. '/uploads/'".$_FILES['thefile']['name'])) { Array ( [thefile] => Array ( [name] => civic.jpg [type] => image/jpeg [tmp_name] => /tmp/php2HAf4A [error] => 0 => 102006 ) ) Error I tryed /httpdocs/uploads/ also, which is up there but I don't know how to get my full path? Link to comment https://forums.phpfreaks.com/topic/42354-solved-upload-form/page/2/#findComment-206195 Share on other sites More sharing options...
monk.e.boy Posted March 13, 2007 Share Posted March 13, 2007 echo $_SERVER['DOCUMENT_ROOT']. '/uploads/'. $_FILES['thefile']['name'] .'<br>'; if (move_uploaded_file($_FILES['thefile']['tmp_name'], $_SERVER['DOCUMENT_ROOT']. '/uploads/'. $_FILES['thefile']['name'] )) { Try that, can you post what is echo'd? Note that I have changed the quotes. cheers, monk.e.boy Link to comment https://forums.phpfreaks.com/topic/42354-solved-upload-form/page/2/#findComment-206221 Share on other sites More sharing options...
aebstract Posted March 13, 2007 Author Share Posted March 13, 2007 O.O that uploaded the image, it also echoed: /var/www/vhosts/hillmarketinggroup.com/httpdocs/uploads/civic.jpg Could you explain what you did to make it work? Thanks a lot for all the help too. edit: is there a way to change the file name as it is being uploaded? Link to comment https://forums.phpfreaks.com/topic/42354-solved-upload-form/page/2/#findComment-206224 Share on other sites More sharing options...
monk.e.boy Posted March 13, 2007 Share Posted March 13, 2007 if (move_uploaded_file($_FILES['thefile']['tmp_name'], $_SERVER['DOCUMENT_ROOT']. '/uploads/'. $_FILES['thefile']['name'] )) You had quotes around the $_SERVER so your resulting string would be very odd. You have two options: if (move_uploaded_file($_FILES['thefile']['tmp_name'], $_SERVER['DOCUMENT_ROOT']. '/uploads/'. $_FILES['thefile']['name'] )) or if (move_uploaded_file($_FILES['thefile']['tmp_name'], "$_SERVER['DOCUMENT_ROOT']/uploads/$_FILES['thefile']['name']" )) Note the position of the ' and the " in my examples and in your code: if (move_uploaded_file($_FILES['thefile']['tmp_name'], "$_SERVER['DOCUMENT_ROOT']. '/uploads/'".$_FILES['thefile']['name'])) { $_SERVER['DOCUMENT_ROOT'] is where you .php file lives on the server. So if this php file is in the root HTML directory and your images folder is in the same directory, then everything matches: /var/www/html/my_page.php /var/www/html/images/img.png then apache sees: http://www.site.com/my_page.php http://www.site.com/images/img.png So $_SERVER['DOCUMENT_ROOT'] = /var/www/html/ $_SERVER['DOCUMENT_ROOT'].'/images/' = /var/www/html/images/ hope that makes sense. monk.e.boy Link to comment https://forums.phpfreaks.com/topic/42354-solved-upload-form/page/2/#findComment-206230 Share on other sites More sharing options...
aebstract Posted March 13, 2007 Author Share Posted March 13, 2007 Yes, thanks for all your help. Now I am going to integrate this in with some database stuff so I may be back in a little bit, hopefully I can get it all to work smoothly Thanks again! Link to comment https://forums.phpfreaks.com/topic/42354-solved-upload-form/page/2/#findComment-206235 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.