简体   繁体   English

PHP是否有办法访问服务器上的文件并仅保存文件的前半部分?

[英]Is there a way with PHP to access a file on a server and save only the first half of the file?

I want to give users a preview of certain files on my site and will be using scribd API. 我想为用户提供我网站上某些文件的预览,并且将使用scribd API。 Does anyone know how I can access the full file from my server and save the file under a different name , which I will then show to users..Can't think of a way to do this with PHP for .docx and image files...Help is much appreciated. 有谁知道我可以如何从服务器访问完整文件并以另一个名称保存文件,然后将其显示给用户。无法想到使用PHP来实现.docx和图像文件的方法。 ..非常感谢您的帮助。

For "splitting" images, use an image processing library like gd to crop the image (lots of examples to be found on how to do that all over the place). 对于“分割”图像,请使用gd之类的图像处理库来裁剪图像(有关如何在整个地方进行操作的许多示例)。 For Word documents, use a library like PHPWord (or one of the other myriad such libraries) to open the document, remove/extract as much text as you need, then save that into a new Word file. 对于Word文档,请使用PHPWord之类的库(或其他众多此类库之一)打开文档,根据需要删除/提取尽可能多的文本,然后将其保存到新的Word文件中。

For other file types, find the appropriate method that allows you to manipulate that format, then do whatever you need to do with it. 对于其他文件类型,请找到允许您操纵该格式的适当方法,然后执行所需的任何操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM