Jump to content

[SOLVED] upload form


aebstract

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.