File upload not working

xxsmith9

New Member
Messages
7
Reaction score
0
Points
0
Hi all, I have a webiste that works fine on my local machine but now I have uplaoded it to x10 its not working correctly. I got past the error 500 problem but my $_FILES array is empty which, I think, means my file is not uploading. I believe its may to do with the permissions on the tmp folder but I am not sure and any help would be appreciated.
The form code is:

Choose a file to upload: <input name="userfile" type="file" />
<input type="submit" value="submit" />

which runs a php script

$target = $target . basename($_FILES['upload']['name']);
setMess($_FILES);

if I echo $target it returns nothing. setMess prints a message back to the previous page. This prints nothing. If iI put in setMess('hello') this retuns hello to screen so I know the script it running.

Thanks
 

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
Could you please post the full copies of the code, because it's difficult to see the problem from small parts of the code.
 

xxsmith9

New Member
Messages
7
Reaction score
0
Points
0
ok the relevant bits are from the upload form

<form action="picfiletransport.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
Choose a file to upload: <input name="userfile" type="file" />
<input type="submit" value="submit" />
</form>

from the picfiletransport.php

<?php
session_start();
require_once('Incs/validationFunctions.inc.php');
$host="localhost";
$user="*";
$password="*";
$dbname = "*";
$cxn = mysqli_connect($host, $user, $password, $dbname)
or die ("Couldn’t connect to server.");


$logname = $_SESSION['logname'];
$albID = $_SESSION['albumIDNUM'];

if (!isset($_SESSION['eventIDNUM']))
{
header("Location: selectevent.php");
}


$eID = $_SESSION['eventIDNUM'];

$target = '/uploadedimages/';
$target = $target . basename($_FILES['upload']['name']);
setMess($_FILES);

if ($_FILES["userfile"]["error"] > 0)
{
setMess("Return Code: " . $_FILES["file"]["error"]);
}




...
?>

function setMess($ms)
{
$_SESSION['uploadMess'] = $ms;
}


I think the rest is irrelevant. This worked on an IIS setup but not on x10. The script definitely gets called! Which folder is used on X10 as the tmp fodler and what shoudl its permissions be? I think this is the problem.

Cheers
 

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
I think I know your problem, have you checked which version of x10hosting php you have?

The mysqli extension may only be accessable if you upgrade to the intemediete version which can be done in your account editting area, which is here.

Edit, Some testing shows that you need to add 'enctype="multipart/form-data"' to your form tag.

Have a look at this tutorial.
http://hudzilla.org/phpwiki/index.php?title=Handling_file_uploads

Here is some working edited code.

HTML:
<form enctype="multipart/form-data"  action="picfiletransport.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
Choose a file to upload: <input name="userfile" type="file" />
<input type="submit" value="submit" />
</form>

PHP:
<?php

$target = '/uploadedimages/';
$target = $target . basename($_FILES['upload']['name']);
setMess($_FILES);

function setMess($ms)
{
	$_SESSION['uploadMess'] = $ms;
}
var_dump($_SESSION['uploadMess']);
?>

Here is an example of that code in action.
Hopefully that solves your problem. :)
 
Last edited:

xxsmith9

New Member
Messages
7
Reaction score
0
Points
0
NO NO NO! That was yesterdays problem :) it won't even accept the form upload unless you have intermediate php. I have this know so we are onto the next problem!
If anyone has a script they *KNOW* works on X10 then that would be great to at least test.

Cheers
 

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
NO NO NO! That was yesterdays problem :) it won't even accept the form upload unless you have intermediate php. I have this know so we are onto the next problem!
If anyone has a script they *KNOW* works on X10 then that would be great to at least test.

Cheers

Add "enctype="multipart/form-data"" to your form tag!!!

Sry, it was just a suggestion. Have you tried the code which I posted in my edit and the example which is on my site? Because I *KNOW* that it works on x10 hosting and you can see it too.

Because that seems to fix your problem, and if it doesn't then the problem is not in the code you have provided.

Edit: I also found a tutorial in the tutorials section for php uploads.
 
Last edited:

xxsmith9

New Member
Messages
7
Reaction score
0
Points
0
Thanks verbsite and apologies for not reading your post fully before running off!!! I took out the form type to test something else and forgot to put it back in!! DOH. Its a case of not seeing the wood for the trees!!!!

Thanks man! (or is it person these days)
 

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
Glad I could help, I think I was probably editing the post while you were posting, so that meant that you didn't read it, I should probably use the editing function less. :)
 

tittat

Active Member
Messages
2,478
Reaction score
1
Points
38
I have a webiste that works fine on my local machine but now I have uplaoded it to x10 its not working correctly.


so the problem is not with the scripts?right?

scripts must not be assigned CHMOD greater than 755
the CHMOD must be 644 or 755 .
 
Top