Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 05-05-2008, 06:56 PM file upload script
Junior Talker

Posts: 3
Name: Parker Ituk
Trades: 0
i see the error below when i try uploading a file to my website,can someone help me out..thanks;

Warning: mkdir(/resume): Read-only file system in /home/www/recruitment.parkerituk.com/homework.php on line 22

Warning: move_uploaded_file(/resume/ituk.doc): failed to open stream: No such file or directory in /home/www/recruitment.parkerituk.com/homework.php on line 27

Warning: move_uploaded_file(): Unable to move '/tmp/phpO3ZLMI' to '/resume/ituk.doc' in /home/www/recruitment.parkerituk.com/homework.php on line 27

find below my php code (homework.php):

<form action="homework.php" enctype="multipart/form-data" method="post">
Last Name:<br /> <input type="text" name="name" value="" /><br />
Homework:<br /> <input type="file" name="homework" value="" /><br />
<p><input type="submit" name="submit" value="Submit Notes" /></p>
</form>

<?php

# Set a constant
define ("FILEREPOSITORY","/resume");

if (isset($_FILES['homework'])) {

if (is_uploaded_file($_FILES['homework']['tmp_name'])) {

if ($_FILES['homework']['type'] != "application/msword") {
echo "<p>Homework must be uploaded in WORD format.</p>";
} else {
/* Format date and create daily directory, if necessary. */
$today = date("m-d-Y");
if (! is_dir(FILEREPOSITORY)) {
mkdir(FILEREPOSITORY);
}

/* Assign name and move uploaded file to final destination. */
$name = $_POST['name'];
$result = move_uploaded_file($_FILES['homework']['tmp_name'], FILEREPOSITORY."/"."$name.doc");

/* Provide user with feedback. */
if ($result == 1)
echo "<p>File successfully uploaded.</p>";
else
echo "<p>There was a problem uploading the homework.</p>";
}
}
}
?>


parkerproject is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-05-2008, 07:24 PM Re: file upload script
Average Talker

Posts: 20
Name: Levi
Trades: 0
For the first error you need to make sure the folder the files are being uploaded to is set to allow writing by users. In fireftp or any ftp program you should be able to right click and go to properties and it will show the permissions for the folder.
Levi_ is offline
Reply With Quote
View Public Profile
 
Old 05-05-2008, 07:24 PM Re: file upload script
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
PHP Code:
define ("FILEREPOSITORY","/resume"); 
This is your error.
You are trying to create a directory "/resume" at the root of the server filesystem, not on the root of your web site.

If you are using apache, you can get the mapping to the web site root via
PHP Code:
define ("FILEREPOSITORY",$_SERVER['DOCUMENT_ROOT']."/resume"); 
This should resolve your problem
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 05-07-2008, 03:38 PM Re: file upload script
Junior Talker

Posts: 3
Name: Parker Ituk
Trades: 0
i still got problem,the script is not uploading file to the specified folder:
do i need to change anything in this code:

define ("FILEREPOSITORY",$_SERVER['DOCUMENT_ROOT']."/resume");

because my site is a sub-domain,so am confused how to mapp it,something like this [parker/recruitment]

thanks for your reply
parkerproject is offline
Reply With Quote
View Public Profile
 
Old 05-07-2008, 05:30 PM Re: file upload script
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
In some rare case, the DOCUMENT_ROOT can be null, which would lead to the same error as previously.
Can you print the value of the target path ?
PHP Code:
echo "<pre>".FILEREPOSITORY."</pre>"
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 05-08-2008, 10:49 AM Re: file upload script
Junior Talker

Posts: 3
Name: Parker Ituk
Trades: 0
i have decided to use another upload script..and is working fine
i was wondering ,if i want to provide a user with a link to its CV in the folder,so that a user can always click on a link to open his current cv ..how can i do that

THANKS
parkerproject is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to file upload script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.36735 seconds with 12 queries