neoPhp Plugin 3.4 - Forum

Forum Navigation
You need to log in to create posts and topics.

neoPhp Plugin 3.4

I have updated neoPhp plugin so it's now possible to work with files without defining their exact name in advance.
Now it's possible to write files on the server from Base64 enconded strings.

Until now it was necessary to add this code on config.php to be able to write to a file whose name was "test.txt" without doing any user login:

$fileAlias[0]="file1";
$fileNames[0]="test.txt";
$filePermissions[0]="rw";
$fileMaxUserLevel[0]=-1;

Then, to write content we used:

neoPhpFileWrite "file1" "Content to write" false ""

But, what if we want to allow the user to write to any .txt file? Now it's possible by adding these lines into config.php:

$fileAlias[0]="*.txt";
$fileNames[0]="*.txt";
$filePermissions[0]="rw";
$fileMaxUserLevel[0]=-1;

And then using the "real" file name, including the extension, instead of an alias:

neoPhpFileWrite "myfile.txt" "Content to write" false ""

Or, if you want to write the file inside a folder:

neoPhpFileWrite "myfolder/myfile.txt" "Content to write" false ""

You can do it for other file extensions too (.jpg and .png for example):

$fileAlias[1]="*.jpg";
$fileNames[1]="*.jpg";
$filePermissions[1]="rw";
$fileMaxUserLevel[1]=-1;

$fileAlias[2]="*.png";
$fileNames[2]="*.png";
$filePermissions[2]="rw";
$fileMaxUserLevel[2]=-1;

And then "upload" the image files using the new command neoPhpFileWriteFromBase64:

SetVar [img] " data:image/jpeg;base64,/9j/4AAQSk.....complete base64 code here"
neoPhpFileWriteFromBase64 "files/myimage.jpg" "[img]" ""

Any not explicitly allowed file type will fail.

As you can see, this is very useful but please be very careful if you decide to allow your app users to upload content to the server as it could be a door for attacks.
Let me know if you have any doubts.

This plugin version will be published with the next VisualNEO Web version.

 

 

 

Uploaded files:
  • You need to login to have access to uploads.
Vadim, farhad2008 and 4 other users have reacted to this post.
Vadimfarhad2008CDY@44DarbdenralPalamarroccocogliano

Thanks @luishp, this is very useful

luishp has reacted to this post.
luishp

@luishp

Thank you so much for the new features!!!

luishp has reacted to this post.
luishp

I am really thank you. Just now I test it and works fine.

luishp has reacted to this post.
luishp

@luishp

Estoy probando la opcion de subir una foto al servidor mediante la nueva funcion que agregastes en Base64, logro subirlo sin problemas siempre y cuando dentro de la funcion ponga el nombre del archivo a generar y la extension del mismo, pero sino le pongo extension ya no lo genera, ahora bien, yo la imagen la cargo mediante :

LocalBinaryFileToBase64Var "FileInput2" [Imagen]

y luego la subo usando tu nueva funcion:

neoPhpFileWriteFromBase64 "fot1" "[Imagen]" ""

Pero no siempre se que extension tiene la imagen cargada

Se puede saber de alguna manera la extension de la misma y dependiendo de ella generar el archivo correcto a subir?

 

Se puede saber de alguna manera la extensión de la misma y dependiendo de ella generar el archivo correcto a subir?

@gustavo1973 si que se puede. Simplemente comprobando los primeros caracteres del texto que compone la codificación en Base64.
Por ejemplo si contiene "data:image/jpeg;base64" será una imagen .jpg. Si contiene "data:image/png;base64" será una imagen .png. Sucede lo mismo para otros tipos de imágenes y archivos como PDF.

Saludos.

Open chat
1
Do you need more info?
Hi, do you have any doubt?