Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Problem with file upload ...

Links for php scripts

Moderators: macek, egami, gesf

Problem with file upload ...

Postby drimades » Sat Feb 05, 2005 2:31 am

---------------------------------------------

This is part of my form Html:


<input type="hidden" name="MAX_FILE_SIZE" value="100000">
&nbsp<INPUT class="bluefldclass" TYPE="file" Name="fotopath" Value="" style="width: 240pt"></TD>
</tr>
<TR><td colspan="4" align="center"><br><INPUT CLASS="bluefldclass" TYPE=SUBMIT Name="submit" Value="Continue" style="width: 100pt">



... and the respective Php:

$file_src = $DOCUMENT_ROOT."/fotot/".$HTTP_POST_FILES['fotopath']['name'];
if (is_uploaded_file($fotopath)) {
move_uploaded_file($fotopath, $file_src);
chmod($file_src, 0644);}



The upload doesn't work! It recognizes the name of the file, but it doesn't upload the file.

---------------------------------------------
drimades
New php-forum User
New php-forum User
 
Posts: 39
Joined: Wed Oct 29, 2003 2:11 pm

Postby Alexej Kubarev » Sat Feb 05, 2005 2:50 am

Check that you have permitions to uploade to that folder..
User avatar
Alexej Kubarev
Site Admin
Site Admin
 
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län

Postby drimades » Sat Feb 05, 2005 10:14 am

-------------------------------------------------------

I'm asking to the hosting company but without any answer yet.

Can I check it myself?

-------------------------------------------------------
drimades
New php-forum User
New php-forum User
 
Posts: 39
Joined: Wed Oct 29, 2003 2:11 pm

Postby Alexej Kubarev » Sat Feb 05, 2005 1:10 pm

sure... FTP client should allow you to right click on a folder and check what chmod do you have... no need to ask a hosting company because you have permisions to do that manualy, but you need to allow your script to do that..
User avatar
Alexej Kubarev
Site Admin
Site Admin
 
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län

Postby drimades » Sun Feb 06, 2005 1:21 am

-------------------------------------------------

For the directory "fotot" I have these rights:

owner rw
group rw
others rw

The script still doesn't work! :(

-------------------------------------------------
drimades
New php-forum User
New php-forum User
 
Posts: 39
Joined: Wed Oct 29, 2003 2:11 pm

Postby Alexej Kubarev » Sun Feb 06, 2005 2:17 am

Code: Select all
$file_src = $_SERVER['DOCUMENT_ROOT']."/fotot/".$_POST['fotopath']['name'];

if (is_uploaded_file($_POST['fotopath'])) {
move_uploaded_file($_POST['fotopath'], $file_src);
chmod($file_src, 0644);
}
User avatar
Alexej Kubarev
Site Admin
Site Admin
 
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län

Postby drimades » Sun Feb 06, 2005 2:38 am

------------------------------------------------

It passes to the else block (so is_uploaded_file($_POST['fotopath'])='false')

:help:

------------------------------------------------
drimades
New php-forum User
New php-forum User
 
Posts: 39
Joined: Wed Oct 29, 2003 2:11 pm

Postby Alexej Kubarev » Sun Feb 06, 2005 3:44 am

OMG! i just saw the error! :)

Use $_FILES instead of $_POST
User avatar
Alexej Kubarev
Site Admin
Site Admin
 
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län

Postby drimades » Sun Feb 06, 2005 11:47 am

--------------------------------------------

The same result! :(

--------------------------------------------
drimades
New php-forum User
New php-forum User
 
Posts: 39
Joined: Wed Oct 29, 2003 2:11 pm

Postby drimades » Tue Feb 08, 2005 3:31 am

-----------------------------------------

It prints all the data of the array $_FILES['fotopath'] exactly but it doesn't recognize it as uploaded ...

:shock:

-----------------------------------------
drimades
New php-forum User
New php-forum User
 
Posts: 39
Joined: Wed Oct 29, 2003 2:11 pm

Postby Alexej Kubarev » Tue Feb 08, 2005 4:23 am

try without uploaded file recognizing...because you cant fill the $_FILES with something unless the file is uploaded :)
User avatar
Alexej Kubarev
Site Admin
Site Admin
 
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län

Postby drimades » Tue Feb 08, 2005 4:51 am

--------------------------------------------

Solved finally!

It was just a matter of permissions. :)

Thank you!

--------------------------------------------
drimades
New php-forum User
New php-forum User
 
Posts: 39
Joined: Wed Oct 29, 2003 2:11 pm

Postby Alexej Kubarev » Tue Feb 08, 2005 7:32 am

well i told you to check them... however now i see that you hadnt 767 :)
User avatar
Alexej Kubarev
Site Admin
Site Admin
 
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län

Postby Tudy » Sun May 15, 2005 2:30 am

I have a question.

How I can make a "Browse..." button for an uploading form ? Thanks.
Tudy
New php-forum User
New php-forum User
 
Posts: 11
Joined: Sun May 15, 2005 12:51 am
Location: Cluj-Napoca

Postby Virtuoso » Sun May 15, 2005 5:08 am

Make something like this:
Code: Select all
<input type='file'>


It will have the browse button beside it.
User avatar
Virtuoso
php-forum Active User
php-forum Active User
 
Posts: 268
Joined: Mon Jul 21, 2003 7:05 am

Postby Tudy » Sun May 15, 2005 5:25 am

I don't understand. I want a button that opens "browse file" window. Is that the code ?
Tudy
New php-forum User
New php-forum User
 
Posts: 11
Joined: Sun May 15, 2005 12:51 am
Location: Cluj-Napoca

Postby Virtuoso » Sun May 15, 2005 5:40 am

<form>
<input type='file'>
</form>


This is the basic code for it.
User avatar
Virtuoso
php-forum Active User
php-forum Active User
 
Posts: 268
Joined: Mon Jul 21, 2003 7:05 am

Postby Tudy » Sun May 15, 2005 7:27 am

Thank you.
Tudy
New php-forum User
New php-forum User
 
Posts: 11
Joined: Sun May 15, 2005 12:51 am
Location: Cluj-Napoca


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron