What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » A little help with php please

A little help with php please
Author: Message:
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
O.P. A little help with php please
Ok guys,
I have coded a File upload system with a password Here
and it will not upload the file here is the code:
code:
<?php
$status = $_GET['upload'];
if  ($status=='1')
{
$form_password = $_POST['password'];
include("config.php");
if ($form_password == $password)
{
copy("$file","$upload_folder");
echo "<center><div class='norm'><b> was successfully uploaded To go to the file you have uploaded go to http://www.files.cloakshape.org/files</b></div></center>";
}
else
{
echo "<center><div class='norm'><b>The upload password was not correct, please go back and re-enter the password correctly.</b></div></center>";
}
}
else
{
?>
<div class="norm">This is a upload system, currently in progress of making </div>
<br>
<form action="<?php
$self_file = $_SERVER['PHP_SELF']; echo "$self_file"; ?>?upload=1" method="post" enctype="multipart/form-data" name="form1">
<table width="300" border="0" align="center">
  <tr>
    <td class="field">Password</td>
    <td><input name="password" type="password"></td>
  </tr>
  <tr>
    <td class="field">File to upload</td>
    <td><input name="file" type="file" class="upload"></td>
  </tr>
  <tr>
    <td width="336"><input type="submit" name="Submit" value="Upload" class="button"></td>
  </tr>
</table>
<?php
}
?>
</form>
</div>
</body>
</html>

then the external file (config.php)
code:
<?php

$password = '(my password)';

$upload_folder = '/files/';

?>


And it wont upload it too the files bit in my sever :S
Thanks for any help
Nathan
Touch Innovation - touch friendly programs/applications for the windows mobile!


06-20-2006 04:48 PM
Profile E-Mail PM Web Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: A little help with php please
I think you first need to do something so that $file will know what $_POST['file'] is...

Haven't coded PHP for a while, I could be wrong :)

By the way, I think it's not simply using copy function, you need something else to reach the uploaded file temporarily stored somewhere on the server., ah, I retract, perhaps you just forgot $file=$_POST['file'] :)

Take a look at http://www.php.net/manual/en/features.file-upload...upload.post-method

This post was edited on 06-20-2006 at 04:55 PM by Mnjul.
06-20-2006 04:50 PM
Profile PM Web Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
O.P. RE: A little help with php please
huh...
could you just edit the code cos i am not sure what you mean :p
Thansk
Touch Innovation - touch friendly programs/applications for the windows mobile!


06-20-2006 05:08 PM
Profile E-Mail PM Web Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: A little help with php please
before this line:
code:
copy("$file","$upload_folder");

add $file=$_POST['file'];
so that it becomes
code:
$file=$_POST['file'];
copy("$file","$upload_folder");


Give it a try :)
06-20-2006 05:15 PM
Profile PM Web Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
O.P. RE: A little help with php please
Thanks,
But nope it doesnt :(
Touch Innovation - touch friendly programs/applications for the windows mobile!


06-20-2006 05:19 PM
Profile E-Mail PM Web Find Quote Report
Plik
Veteran Member
*****

Avatar

Posts: 1489
Reputation: 46
35 / Male / –
Joined: Jun 2004
RE: A little help with php please
Read through this: http://www.php.net/manual/en/features.file-upload.php

(i know i already said this on msn, but it will save anyone else the effort
06-20-2006 05:34 PM
Profile PM Find Quote Report
hmaster
Senior Member
****

Avatar

Posts: 716
Reputation: 24
33 / Male / Flag
Joined: Nov 2004
RE: A little help with php please
This is some sample upload code I used, I think it's because you havn't used the $_FILES variables

code:
    #upload

    if(@$_POST['submit']) {
        $target_path = "gallery/images/";
        $filename = basename($_FILES['uploadedfile']['name']);
        $filename = str_replace(" ", "", $filename);
        $target_file = $target_path . $filename;
           
            if(empty($filename) || $filename == " ") {
            header("Location: upload.php?error=1");
            } elseif(file_exists($target_file) && @$_POST['ovrwrtf'] != "on") {
            header("Location: upload.php?error=3");
            } else {
                if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_file)) {
                    header("Location: img.php?filename=$filename");
                } else {
                header("Location: upload.php?error=4");
                }
           }
    }
?>

I think move_uploaded_file() works better than copy() when uploading *-)

This post was edited on 06-20-2006 at 05:50 PM by hmaster.
[Image: sig.png]
06-20-2006 05:47 PM
Profile PM Web Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
36 / Male / Flag
Joined: Mar 2004
RE: RE: A little help with php please
quote:
Originally posted by hmaster
This is some sample upload code I used, I think it's because you havn't used the $_FILES variables

code:
    #upload

    if(@$_POST['submit']) {
        $target_path = "gallery/images/";
        $filename = basename($_FILES['uploadedfile']['name']);
        $filename = str_replace(" ", "", $filename);
        $target_file = $target_path . $filename;
           
            if(empty($filename) || $filename == " ") {
            header("Location: upload.php?error=1");
            } elseif(file_exists($target_file) && @$_POST['ovrwrtf'] != "on") {
            header("Location: upload.php?error=3");
            } else {
                if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_file)) {
                    header("Location: img.php?filename=$filename");
                } else {
                header("Location: upload.php?error=4");
                }
           }
    }
?>

I think move_uploaded_file() works better than copy() when uploading *-)


Horrible use isset() instead of just ignoring the notice

This post was edited on 06-21-2006 at 03:49 AM by -dt-.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
06-21-2006 03:48 AM
Profile PM Web Find Quote Report
Lou
Veteran Member
*****

Avatar

Posts: 2475
Reputation: 43
– / Male / Flag
Joined: Aug 2004
RE: A little help with php please
I made an uploader. Alright, there's no password protect, but you can just re-implement it in here.

The code is not 100% mine I admit it:P

EDIT: It seems I had removed the file extension blocker..You might want to add that back in if you ever remove that password.

.zip File Attachment: working uploader.zip (1.39 KB)
This file has been downloaded 176 time(s).

This post was edited on 06-21-2006 at 04:01 AM by Lou.
[Image: msghelp.net.png]
The future holds bright things in it\\\'s path, but only time will tell what they are and where they come from.
Messenger Stuff Forums
06-21-2006 03:58 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On