PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 7th, 2000, 01:49 AM
digjen digjen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 58 digjen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 m 9 sec
Reputation Power: 14
How do I upload a file to the same directory as my 'upload.php' file?

Is it possible to do this without having knowning the hole filesystem tree.

I've tried alot of things but don't get it to work

Reply With Quote
  #2  
Old June 10th, 2000, 02:14 AM
raghuram
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Use the File Data Type to do this.

<html>
<body>
<form enctype="multipart/form-data" method="post"
action="<?php echo $PHP_SELF ?>">
<input type="File" name="blah" size="25"><br>
<input type="submit" name="submit" value="Upload">
</form>
<?php
if ($submit) {
exec("cp $blah complete path of your folder/$filename");
//syntax for cp - cp Uploading File, Path where the file to be Uploaded.


Enjoy

Raghu.
}
?>
</body>
</html>


Reply With Quote
  #3  
Old June 10th, 2000, 02:16 AM
raghuram
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by raghuram:
Use the File Data Type to do this.

<html>
<body>
<form enctype="multipart/form-data" method="post"
action="<?php echo $PHP_SELF ?>">
<input type="File" name="blah" size="25"><br>
<input type="submit" name="submit" value="Upload">
</form>
<?php
if ($submit) {
exec("cp $blah complete path of your folder/$filename");
//syntax for cp - cp Uploading File, Path where the file to be Uploaded.
}
?>
</body>
</html>
[/quote]


Enjoy

Raghu.

Reply With Quote
  #4  
Old June 10th, 2000, 08:52 AM
Mirax's Avatar
Mirax Mirax is offline
Senior Member
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2000
Location: Enschede, The Netherlands
Posts: 1,527 Mirax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 55 m 57 sec
Reputation Power: 14
Hi Raghu,

I tried your code but somehow it didn't work with me. Maybe I didn't get the path-thing right, but I changed the code somewhat and now I can upload a file into a directory 'files', which is located in the same directory as my upload-script. So far so good!

The problem is though I don't know how I can give the uploaded file the same name as the original. $blah is always C:WindowsTempPhp2 with me, so with my current script I get a file called php2. Is there a way to get this right?

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
<html>
<body>

<form enctype="multipart/form-data" method="post" action="<?php echo $PHP_SELF ?>">
<input type="File" name="blah" size="25"><br>
<input type="submit" name="submit" value="Upload">
</form>

<?php
if ($submit) {
$dir = "files";
$filename = basename($blah);
if (!copy($blah, $dir.$filename)) {
print( "Oops! Something went wrong!");
}
}
?>

</body>
</html>
[/code]

Mirax

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > File uploading

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap