Jump to content

Files to Functions


Guest

Recommended Posts

To upload the file use this one

[code]
<?php
<form enctype="multipart/form-data" action="_URL_" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>
?>

[/code]

Once you upload the file you can pass the file name to any function ($_FILES['file']['usefile'])

Link to comment
https://forums.phpfreaks.com/topic/26917-files-to-functions/#findComment-123103
Share on other sites

I tried to pass the file to the function and the function has no data if i upload an image name image1 and type file
i send it to the function by $_FILES['image1'] and there is also no data inside the function lets say i wanted to get the size and the name in the function how would i send the file and how would i recive the file would i use $image or what on the function definition?
Link to comment
https://forums.phpfreaks.com/topic/26917-files-to-functions/#findComment-123104
Share on other sites

I do this
[code]function getFileExtension($str) {
    $i = strrpos($str,".");
    if (!$i) { return ""; }
    $l = strlen($str) - $i;
    $ext = substr($str,$i+1,$l);
    return $ext;
}

$ext = getFileExtension($_FILES['image1']['name']);
[/code]

$ext is blank i cant figue out why the functions are in different files included of course
Link to comment
https://forums.phpfreaks.com/topic/26917-files-to-functions/#findComment-123214
Share on other sites

[code]
getimagesize($_FILES['image1']['tmp_name'])

Warning: getimagesize(/tmp/phpSULyxK) [function.getimagesize]: failed to open stream: No such file or directory in imagefunctions.php on line 81

Warning: copy(/tmp/phpSULyxK) [function.copy]: failed to open stream: No such file or directory in
[/code]

I dont get whats going on if its not in functions all this works correctly. Is there somthing im missing am i doing it wrong?
Link to comment
https://forums.phpfreaks.com/topic/26917-files-to-functions/#findComment-123250
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.