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
file submission (sorry for such a silly question)
Old 12-04-2007, 03:52 PM file submission (sorry for such a silly question)
Junior Talker

Posts: 4
Name: Patricia
Trades: 0
I'm sorry for asking such a silly question, but I know nothing about php (just plain HTML), so I'm having trouble to use a file submission form on my website.
I'm using hosting services from hyperphp.com (a free web hosting that allows php), and I found this code:

<form action="upload.php" method="post" enctype="multipart/form-data" name="form1">
<p align="center">Archivo
<input name="archivo" type="file" id="archivo">
</p>
<p align="center"><input name="boton" type="submit" id="boton" value="Enviar"></p>
</form>


Then the code for the php file ("upload.php"), which would be:

<?
if($boton) {
if (is_uploaded_file($HTTP_POST_FILES['archivo']['tmp_name'])) {
copy($HTTP_POST_FILES['archivo']['tmp_name'], $HTTP_POST_FILES['archivo']['name']);
$subio = true;
}

if($subio) {
echo "El archivo subio con exito";
} else {
echo "El archivo no cumple con las reglas establecidas";
}
die();
}
?>


I uploaded the "upload.php" file to my web server and tried sending a file through the form, but it doesn't work. I know there's some step missing, but since I'm completely dumb about php, I don't know what it is.
Could any good heart help me please?
patr1c1a is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-04-2007, 04:24 PM Re: file submission (sorry for such a silly question)
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
What happens when you try to upload something ?
Do you get an error message, or something ?

The way I see this code, PHP will try to write the file at the same place that this script.
But this could fail if PHP had only reading permissions on the current folder.
Or maybe the file upload is disabled, as some functions can be disabled in safe mode...

Another thing is that often free hosting restrict the maximum size of the files. So, if your file is bigger that this limit (and if there is one) maybe that the file is silently discarded from the directory.
__________________
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 12-04-2007, 04:33 PM Re: file submission (sorry for such a silly question)
Junior Talker

Posts: 4
Name: Patricia
Trades: 0
No, I don't get any error messages, just a blank page. I tried with a different script and I got an error message saying the file could't be uploaded (because the script was set to show that if there was a problem). I tried with a 10kb file, so it can't be the size.
Maybe I have to set up something on my hosting control panel? I've seen a lot of databases things I don't understand. Could it be that?
Thanks
patr1c1a is offline
Reply With Quote
View Public Profile
 
Old 12-04-2007, 05:22 PM Re: file submission (sorry for such a silly question)
Novice Talker

Posts: 5
Name: Dan Mahoney
Trades: 0
Quote:
Originally Posted by patr1c1a View Post
No, I don't get any error messages, just a blank page. I tried with a different script and I got an error message saying the file could't be uploaded (because the script was set to show that if there was a problem). I tried with a 10kb file, so it can't be the size.
Maybe I have to set up something on my hosting control panel? I've seen a lot of databases things I don't understand. Could it be that?
Thanks
I don't think it would be anything database related, since you aren't working with any. All you really are doing is uploading files, not selecting data or inserting data to a database.
__________________

Please login or register to view this content. Registration is FREE


PHP Programming Community owned by me! Needs members!
danmahoney2456 is offline
Reply With Quote
View Public Profile Visit danmahoney2456's homepage!
 
Old 12-04-2007, 07:25 PM Re: file submission (sorry for such a silly question)
Junior Talker

Posts: 4
Name: Patricia
Trades: 0
And the codes I pasted in my first post are correct?
Do you know any other code that might actually work? I only need people to be able to upload image files. I don't know if there's any size restriction, so it would be nice that the code includes a function to reject uploads of files that are bigger than [x].
Thankies!
patr1c1a is offline
Reply With Quote
View Public Profile
 
Old 12-04-2007, 07:36 PM Re: file submission (sorry for such a silly question)
Novice Talker

Posts: 5
Name: Dan Mahoney
Trades: 0
Code:
$path = "uploads/"; 
if(move_uploaded_file($_FILES['htmlformname']['tmp_name'], $path/{$_FILES['htmlformname']['tmp_name']})) {
    print "The file has been uploaded!";
} else{
    print "The file could not be uploaded.";
}
Tell me if that works...It should, I just took out your copy() function.
__________________

Please login or register to view this content. Registration is FREE


PHP Programming Community owned by me! Needs members!
danmahoney2456 is offline
Reply With Quote
View Public Profile Visit danmahoney2456's homepage!
 
Old 12-04-2007, 08:17 PM Re: file submission (sorry for such a silly question)
Junior Talker

Posts: 4
Name: Patricia
Trades: 0
I get an HTTP 500 error page
Thanks for the code anyway
patr1c1a is offline
Reply With Quote
View Public Profile
 
Old 12-04-2007, 08:25 PM Re: file submission (sorry for such a silly question)
Novice Talker

Posts: 5
Name: Dan Mahoney
Trades: 0
did you change the $_FILES['htmlformname'] to your upload field name?
__________________

Please login or register to view this content. Registration is FREE


PHP Programming Community owned by me! Needs members!
danmahoney2456 is offline
Reply With Quote
View Public Profile Visit danmahoney2456's homepage!
 
Old 12-05-2007, 11:34 PM Re: file submission (sorry for such a silly question)
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
Error reporting may be turned off by the hosting default. Try adding the following line to the top of your script:

error_reporting(1);
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is online now
Reply With Quote
View Public Profile
 
Reply     « Reply to file submission (sorry for such a silly question)
 

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.28639 seconds with 12 queries