Forums NFrance

Forum de discussions NFrance - Support offres dédiées et mutualisées

Vous n'êtes pas identifié.

Annonce

Attention, le forum est public, ne postez donc jamais votre mot de passe en clair dans un message.

#1 30-08-2006 19:56:18

Sara
Nouveau membre
Date d'inscription: 30-08-2006
Messages: 8

Path name for file uploads

Hi,

I am an existing discount-hosting customer (domain name www.magdalenausa.org).

I am trying to create an image upload form using the PHP upload script.  In order to do so I need the full file path for my web site.  I also need to ensure that full read/write permissions on the spgm directory in my site.

Can you please assist me with both of these items?

Also, can you please remind me of the size limit for my site?  It used to be on the discount hosting home page but is no longer since the page has changed.

Thanks,
Sara

Hors ligne

 

#2 31-08-2006 11:30:22

analogue
Membre expérimenté
Lieu: Toulouse
Date d'inscription: 14-08-2006
Messages: 114
Site web

Re: Path name for file uploads

Here is a short tutorial for handling file uploads in PHP.

Your webspace is limited to 50MB.


Ex-Support Technique
Bonne continuation !

Hors ligne

 

#3 31-08-2006 16:33:32

Sara
Nouveau membre
Date d'inscription: 30-08-2006
Messages: 8

Re: Path name for file uploads

Thank you for your reply.
I am very familiar with the PHP code and how to write the page to do the uploads.

What I am asking you for is what do I put in this line of the code:

$uploaddir = 'path to upload folder';

It requires I know the *full path* to my web site, which I don't.  Once within the site I know the folder structure, but I don't know the path for it on the server from the root.

Is there a way you can tell me the path?

Thank you!

Hors ligne

 

#4 31-08-2006 16:38:15

analogue
Membre expérimenté
Lieu: Toulouse
Date d'inscription: 14-08-2006
Messages: 114
Site web

Re: Path name for file uploads

You can get your path by looking into the phpinfo() function.

Create a PHP file with the following content:

Code:

<?php phpinfo(); ?>

Ex-Support Technique
Bonne continuation !

Hors ligne

 

#5 31-08-2006 16:58:49

Sara
Nouveau membre
Date d'inscription: 30-08-2006
Messages: 8

Re: Path name for file uploads

Thank you.

Now can you help me get the permissions opened up on both the file upload temp directory and on my site so that I can do uploads?

I am encountering an error that lets me know that at least one of those folders is not writable.
The temp upload directory is /tmp-php/

Thanks,
Sara

Hors ligne

 

#6 31-08-2006 17:02:13

analogue
Membre expérimenté
Lieu: Toulouse
Date d'inscription: 14-08-2006
Messages: 114
Site web

Re: Path name for file uploads

You are not allowed to write in /tmp-php/
Create a "tmp-php" dir in your home directory, do a chmod 0777 on your tmp-php directory, now do the same with an "upload" directory (create and chmod).
Now you can use the following funtion to handle your file uploads:

move_uploaded_file ("$file","upload/$file_name");


Ex-Support Technique
Bonne continuation !

Hors ligne

 

#7 31-08-2006 17:26:53

Sara
Nouveau membre
Date d'inscription: 30-08-2006
Messages: 8

Re: Path name for file uploads

That would have been helpful information to know earlier.  smile

Is there now a support page or area available for discount hosting clients (there never was in the past) that provides information like this or is this forum the best place to do this?

I will try that and get back to you if I have any further issues.

Thanks,
Sara

Hors ligne

 

#8 31-08-2006 17:29:56

analogue
Membre expérimenté
Lieu: Toulouse
Date d'inscription: 14-08-2006
Messages: 114
Site web

Re: Path name for file uploads

The best place is this forum until the FAQ are online at http://www.nfrance.info/ (on the 5th of september)


Ex-Support Technique
Bonne continuation !

Hors ligne

 

#9 10-09-2006 22:34:07

Sara
Nouveau membre
Date d'inscription: 30-08-2006
Messages: 8

Re: Path name for file uploads

Hi,

I have done all you have suggested and it still doesn't work.
The error message I get is:

Array ( [image] => Array ( [name] => wwmiccable.jpg [type] => image/jpeg [tmp_name] => /var/tmp/phppeLlcx [error] => 0 [size] => 6230 ) )

This error message shows me that the PHP upload script is trying to use the /var/tmp directory on the server, even though I have created a /tmp-php folder on my site and chmod the settings to 0777.

When I look in my phpinfo() I see that the upload_tmp_dir is set to ./tmp-php/

What can I do to get my temp directory to be recognized properly?

Thanks,
Sara

Hors ligne

 

#10 10-09-2006 22:44:56

Sara
Nouveau membre
Date d'inscription: 30-08-2006
Messages: 8

Re: Path name for file uploads

Also...I have tried using the ini_set() command to set the temp directory and I have tried creating a /var/tmp directory on my site.  Neither of those have worked.

Your assistance is greatly appreciated.
Sincerely,
Sara

Hors ligne

 

#11 11-09-2006 13:44:32

Siméon
Moderateur
Lieu: Toulouse
Date d'inscription: 10-08-2006
Messages: 3052
Site web

Re: Path name for file uploads

In face the tmp-php described in tutorial depends from the server ...

According to your error message, try to set right permissions to 777 in the folder you want to upload your files (/images/ for ex.) The file seems to be right uploaded on the server but wrong moved, maybe due to unsufficent permissions on destination folder.


Siméon
Ex-support technique NFrance

Hors ligne

 

#12 11-09-2006 22:21:32

Sara
Nouveau membre
Date d'inscription: 30-08-2006
Messages: 8

Re: Path name for file uploads

Thank you for your response.
I have checked permissions on all the folders where the images upload to and they are set to 777.  I am still getting the same error.

I have set proper permissions for both the tmp-php folder and the folders where the images get moved to.

You say the tmp-php depends from the server, do you mean a different tmp-php folder than the one in my site directory or the one that is indeed in my site?

If in my site I have set the permissions to 777, if somewhere else, how can I get the permissions to be set properly.

Can you please check the permissions for the tmp-php folder on the server where my site is hosted and ensure that it is set to 777?

I have successfully created a PHP file upload script just like this on many other hosts, yours is the only one where I am running into this problem.

Thank you for your assistance,
Sara

Hors ligne

 

#13 14-09-2006 12:00:32

Siméon
Moderateur
Lieu: Toulouse
Date d'inscription: 10-08-2006
Messages: 3052
Site web

Re: Path name for file uploads

Ok, I deal a read access to your upload script with administrators smile

Apparently all your images directories are set in 777, so it's ok for uploading files ; but the script try to upload with a full path name (/home/dxxx/...), and maybe he don't find the beginning of the way (due to security rights), so try to set a relative path (spgm/gal/) ...

Otherway all seems to be good, i didn't see specific errors ...


Siméon
Ex-support technique NFrance

Hors ligne

 

#14 14-09-2006 17:50:37

Sara
Nouveau membre
Date d'inscription: 30-08-2006
Messages: 8

Re: Path name for file uploads

Thank you for your response.
I just tried setting the path to be relative and it still didn't work.  I get the same error as before.

Array ( [image] => Array ( [name] => wwmiccable.jpg [type] => image/jpeg [tmp_name] => /var/tmp/phprqsVXj [error] => 0 [size] => 6230 ) ) Error uploading the product image file.

Can you please tell me where the /var/tmp folder is and how I can get the proper permissions set on it?  In the error message this is being shown as the temp upload folder...this folder is not on my site, so it must be somewhere else on the server.

I know (and you have verified) that all the permissions are set correctly on my site.  I need to confirm that the permissions are set correctly for the temp folder (/var/tmp) before I can confirm that this is not a permissions issue.

If this is what you were telling me you did before, please excuse me because I didn't understand.

I really appreciate your assistance.
Sara

Hors ligne

 

#15 18-09-2006 16:44:04

Siméon
Moderateur
Lieu: Toulouse
Date d'inscription: 10-08-2006
Messages: 3052
Site web

Re: Path name for file uploads

I made a few test last week, and it appears that on your server (discount-hosting) we must define a directory named for exemple tmp , with 777 rights to upload files correctly.
/var/tmp/ exists but is not used due security configuration (safe mode) to upload functions.

Here a little script I test and which works :

Code:

if(strlen($_FILES['userfile']['name']) > 0)
{
        $uploaddir = 'tmp/';
        $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

        echo "<p>\n";
        if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
                echo 'Upload du fichier '.$_FILES['userfile']['name'].' reussi !
';
        } else {
                echo 'Upload echoue.';
        }
        echo "</p>\n";

Siméon
Ex-support technique NFrance

Hors ligne

 

Pied de page des forums

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson