There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Error Uploading files


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Boylett's Avatar
Computer Specs
Member with 49 posts.
 
Join Date: Dec 2006
Experience: Intermediate
05-Mar-2007, 02:54 PM #1
Error Uploading files
I am trying to make an upload file php script. This is my upload code:
PHP Code:
<?php

session_start
();

if(!
$_SESSION['logged']) die("You must login first");

$target_path "../uploads/".basename($_FILES['file']['name']); 

if(
move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) 
{
    echo 
"The file ".basename($_FILES['file']['name'])." has been uploaded";
} else {
    echo 
"There was an error uploading the file, please try again!";
}

?>
This is my form to upload the file:
HTML Code:
<form enctype="multipart/form-data" action="uploader.php" method="POST">Choose a file to upload: <input name="file" type="file" /><br /><input type="submit" value="Upload File" /></form>
I get these errors:
Code:
Warning: move_uploaded_file(../uploads/GroveDM.txt): failed to open stream: No such file or directory in /hsphere/local/home/mandymoo/xendot.com/server/backa/uploader.php on line 9

Warning: move_uploaded_file(): Unable to move '/tmp/phpnLT9K7' to '../uploads/GroveDM.pwn' in /hsphere/local/home/mandymoo/xendot.com/server/backa/uploader.php on line 9
There was an error uploading the file, please try again!
What am I doing wrong?
Sequal7's Avatar
Computer Specs
Distinguished Member with 2,369 posts.
 
Join Date: Apr 2001
Location: Around the corner!
Experience: Including today?
05-Mar-2007, 11:33 PM #2
Just a guess, but file location or privileges could be the resulting errors cause.
Can I assume that line 9 on your uplaods.php file is in the code in your first post?

If so, have you tried changing the access to the folder?
If that was tried and did not work, have you tried changing the relative target from $target_path = "../uploads/" to the the actual target of $target_path = "hsphere/local/home/mandymoo/xendot.com/server/uploads/"

Also, you may want to limit the type of files allowed to be uploaded to protect your server.
__________________
Good Luck on your fix

My real hobby..JoyCo
My real Job..(Second Hobby) IAFF Local 1865
Like the sites? My hobby is the one that created them!
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,202 posts.
 
Join Date: Oct 2006
06-Mar-2007, 01:26 AM #3
Worked great for me using this code:

PHP Code:
<?php

$target_path 
"uploads/".basename($_FILES['file']['name']);

if(
move_uploaded_file($_FILES['file']['tmp_name'], $target_path))
{
    echo 
"The file ".basename($_FILES['file']['name'])." has been uploaded";
} else {
    echo 
"There was an error uploading the file, please try again!";
}

?>
You have to create the folder upload by hand.

Nice script btw

Last edited by MMJ : 06-Mar-2007 01:33 AM.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:52 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.