/    Sign up×
Community /Pin to ProfileBookmark

Need help on uploader script !!!

Hi there!

I got this upload script off of the internet, and while testing I encountered some difficulties!

This is the script:

[QUOTE]

<?php
if($userfile) {
copy($userfile, “http://www.ctrl-t.com/upload/files/$userfile_name“); echo “Upload was

successfull!<br>n”;
//$username : contains the name of TMP file, $usrfile_name : it’s the real name of file
}
?>
<form action=”<?php echo $PHP_SELF ?>” method=”post” name=”upload”>
File to Upload: <input type=file name=userfile><BR>
<input type=submit value=”Upload”>
</form>
</body>
</html>

[/QUOTE]

And this was the (unfortunate) result:

[QUOTE]

Warning: Unable to open ‘C:Documents and SettingsTobyMijn documentenMijn afbeeldingenfile_cabinet_squirm_lg_clr.gif’ for reading: No such file or directory in /home/httpd/vhosts/ctrl-t.com/httpdocs/upload/index.php on line 3
Upload was successfull!

[/QUOTE]

[COLOR=red]Can anybody help me, please??????[/COLOR]

Greetz…. ctrl-t

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@SamFeb 18.2004 — you can't upload through the http:// protocol, you need to find the full path to the folder you need. ie. if your php file is @ http://www.ctrl-t.com/upload.php

you could use
[code=php]copy($userfile, getcwd() . "/upload/files/$userfile_name");[/code]
Copy linkTweet thisAlerts:
@ctrl-tauthorFeb 18.2004 — Hey thanks...

Where in my script do I have to put that little line???
Copy linkTweet thisAlerts:
@SamFeb 18.2004 — replace this:

copy($userfile, "http://www.ctrl-t.com/upload/files/$userfile_name");

with mine
Copy linkTweet thisAlerts:
@ctrl-tauthorFeb 18.2004 — I replaced the the line, but stiil I get the error!

My .php is in www.ctrl-t.com/upload/...

so I altered your line to:

[code=php]copy($userfile, getcwd() . "/files/$userfile_name");[/code]
Copy linkTweet thisAlerts:
@SamFeb 18.2004 — not entirely sure what the error is, don't have enough time to figure it out atm, here's the upload script i use:

upload.htm
[code=php]
<!doctype html public "-//W3C//DTD HTML 4.01 //EN">
<html>
<head>
<title>Title here!</title>
</head>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000">
Select a file to upload! <input type="file" name="userfile"><br>
<input type="submit" value="Upload!">
</form>
</body>
</html>
[/code]

upload.php
[code=php]
<?php

if(!(copy($_FILES['userfile']['tmp_name'], "upload/" . $_FILES['userfile']['name']))) die("Cannot upload files.");

echo "Upload Complete!";

?>
[/code]
Copy linkTweet thisAlerts:
@ctrl-tauthorFeb 19.2004 — Hey... Thanx samij586,

This works fine!!!

You are a Saint!
Copy linkTweet thisAlerts:
@SamFeb 19.2004 — no problem, just for your knowledge, if you try to upload a file larger than 5000000 bytes, it won't work, unless you change the MAX_FILE_SIZE
Copy linkTweet thisAlerts:
@ctrl-tauthorFeb 19.2004 — Yeah... I noticed the size-limit allredy.

Would it be possible with this script to add more downloads.

Like 2 or 3 files at the same time??? (for user-conveniance)

Then they wouldn't have to uload 3 seperate files.

(I don't want to be a pest or something.... I'm just curious, and like to learn some PHP at the same time)
Copy linkTweet thisAlerts:
@bluflamez09Nov 23.2005 — hahaha... I thought I could handle something like this, guess not. May I ask where the directory for the image upload is? I though you substitute what you wanted the directory to be from "upload/" but when I put "hosted/user" but I got this error.

Warning: copy(hostedfiles/userlogo.gif): failed to open stream: No such file or directory in /home/bluhost/public_html/upload.php on line 3

Cannot upload files.

I'm such a loser... and don't I have to CHMOD something? I'm probably asking something stupid but I'm relativaly new to PHP code.
×

Success!

Help @ctrl-t spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...